/**
 * Created by yanlin on 2017/10/22.
 */
//checkbox的显示控制
var flag_add = true;

var role = $("input[name='role']").val();
var xzqh_message = new Ext.data.JsonStore({
    url: '/index/xzqhxx/combo.action',
    fields: ['value', 'text']
});
// xzqh_message.on("load", function () {
//     $.post("/qtIndex/xzqhName.action", function (data) {
//         // xzqh_message_combo_add.setValue(data);
//     });
// });
xzqh_message.load();
var flag_store1 = new Ext.data.JsonStore({
    fields: ['value', 'text'],
    data: [
        {text: "是", value: 1},
        {text: "否", value: 0}
    ]
});

var tcflag_combo = new Ext.form.ComboBox({
    name: 'tc',
    fieldLabel: '停测',
    //emptyText: '请选择',
    mode: 'local',
    editable: false,
    triggerAction: 'all',
    store: flag_store1,
    width: 150,
    valueField: 'value', // 值
    displayField: 'text',
    hiddenName: 'tcflag',
    allowBlank: true,
    msgTarget: "side"
});
var tcflag_combo1 = new Ext.form.ComboBox({
    name: 'tc',
    fieldLabel: '停测',
    emptyText: '请选择',
    mode: 'local',
    editable: false,
    triggerAction: 'all',
    store: flag_store1,
    width: 150,
    valueField: 'value', // 值
    displayField: 'text',
    hiddenName: 'tcflag',
    allowBlank: true,
    msgTarget: "side"
});


var xzqh_message_combo_add = new Ext.form.ComboBox({
    name: 'addvnm',
    fieldLabel: '上级行政区名称',
    emptyText: '请选择',
    mode: 'local',
    editable: true,
    triggerAction: 'all',
    store: xzqh_message,
    width: 150,
    valueField: 'value', // 值
    displayField: 'text',
    hiddenName: 'addvcd',
    allowBlank: false,
    msgTarget: "side",
    queryParam: 'userinput',
    forceSelection: true,
    listeners: {
        beforequery: function (qe) {
            var para = qe.query;
        },
        select: function (combo, record, index) {
            // alert(record.json.text);
            // alert(record.json.value);
            Ext.Ajax.request({
                url: '/qtIndex/station/getNewStcd.action?addvcd=' + record.json.value,
                success: function (resp, opts) {
                    var respText = Ext.util.JSON.decode(resp.responseText);
                    station_addform.getForm().findField('stcd').setValue(respText);
                }
            });

        }
    }
});
var xzqh_message_combo_update = new Ext.form.ComboBox({
    name: 'addvnm',
    fieldLabel: '上级行政区名称',
    emptyText: '请选择',
    mode: 'local',
    editable: true,
    triggerAction: 'all',
    store: xzqh_message,
    width: 150,
    valueField: 'value', // 值
    displayField: 'text',
    hiddenName: 'addvcd',
    allowBlank: false,
    msgTarget: "side",
    queryParam: 'userinput',
    forceSelection: true,
    listeners: {
        beforequery: function (qe) {
            var para = qe.query;
        }
    }
});

var hlxx_message = new Ext.data.JsonStore({
    url: '/qtIndex/hlxx/combo.action',
    fields: ['value', 'text']
});
hlxx_message.load();
var hlxx_message_combo_add = new Ext.form.ComboBox({
    name: 'rvnm',
    fieldLabel: '所在河流名称',
    emptyText: '请选择',
    mode: 'local',
    editable: true,
    triggerAction: 'all',
    store: hlxx_message,
    width: 150,
    valueField: 'value', // 值
    displayField: 'text',
    hiddenName: 'rvcd',
    allowBlank: false,
    msgTarget: "side",
    queryParam: 'userinput',
    forceSelection: true,
    listeners: {
        beforequery: function (qe) {
            var para = qe.query;
        }
    }
});
var hlxx_message_combo_update = new Ext.form.ComboBox({
    name: 'rvnm',
    fieldLabel: '所在河流名称',
    emptyText: '请选择',
    mode: 'local',
    editable: true,
    triggerAction: 'all',
    store: hlxx_message,
    width: 150,
    valueField: 'value', // 值
    displayField: 'text',
    hiddenName: 'rvcd',
    allowBlank: false,
    msgTarget: "side",
    queryParam: 'userinput',
    forceSelection: true,
    listeners: {
        beforequery: function (qe) {
            var para = qe.query;
        }
    }
});

var sxxx_message = new Ext.data.JsonStore({
    url: '/qtIndex/sxxx/combo.action',
    fields: ['value', 'text']
});
sxxx_message.load();
var sxxx_message_combo_add = new Ext.form.ComboBox({
    name: 'hnnm',
    fieldLabel: '所属水系名称',
    emptyText: '请选择',
    mode: 'local',
    editable: false,
    triggerAction: 'all',
    store: sxxx_message,
    width: 150,
    valueField: 'value', // 值
    displayField: 'text',
    hiddenName: 'hncd',
    allowBlank: false,
    msgTarget: "side"
});
var sxxx_message_combo_update = new Ext.form.ComboBox({
    name: 'hnnm',
    fieldLabel: '所属水系名称',
    emptyText: '请选择',
    mode: 'local',
    editable: false,
    triggerAction: 'all',
    store: sxxx_message,
    width: 150,
    valueField: 'value', // 值
    displayField: 'text',
    hiddenName: 'hncd',
    allowBlank: false,
    msgTarget: "side"
});

var lyxx_message = new Ext.data.JsonStore({
    url: '/qtIndex/lyxx/combo.action',
    fields: ['value', 'text']
});
lyxx_message.load();
var lyxx_message_combo_add = new Ext.form.ComboBox({
    name: 'bsnm',
    fieldLabel: '所属流域名称',
    emptyText: '请选择',
    mode: 'local',
    editable: false,
    triggerAction: 'all',
    store: lyxx_message,
    width: 150,
    valueField: 'value', // 值
    displayField: 'text',
    hiddenName: 'bscd',
    allowBlank: false,
    msgTarget: "side"
});
var lyxx_message_combo_update = new Ext.form.ComboBox({
    name: 'bsnm',
    fieldLabel: '所属流域名称',
    emptyText: '请选择',
    mode: 'local',
    editable: false,
    triggerAction: 'all',
    store: lyxx_message,
    width: 150,
    valueField: 'value', // 值
    displayField: 'text',
    hiddenName: 'bscd',
    allowBlank: false,
    msgTarget: "side"
});

var czdjxx_message = new Ext.data.JsonStore({
    url: '/qtIndex/czdjxx/combo.action',
    fields: ['value', 'text']
});
czdjxx_message.load();
var czdjxx_message_combo_add = new Ext.form.ComboBox({
    name: 'stgrd',
    fieldLabel: '测站等级',
    //emptyText: '请选择',
    mode: 'local',
    editable: false,
    triggerAction: 'all',
    store: czdjxx_message,
    width: 150,
    valueField: 'value', // 值
    displayField: 'text',
    hiddenName: 'stgrdcd',
    allowBlank: true,
    msgTarget: "side"
});
var czdjxx_message_combo_update = new Ext.form.ComboBox({
    name: 'stgrd',
    fieldLabel: '测站等级',
    //emptyText: '请选择',
    mode: 'local',
    editable: false,
    triggerAction: 'all',
    store: czdjxx_message,
    width: 150,
    valueField: 'value', // 值
    displayField: 'text',
    hiddenName: 'stgrdcd',
    allowBlank: true,
    msgTarget: "side"
});

var czlxxx_message = new Ext.data.JsonStore({
    url: '/qtIndex/czlxxx/combo.action',
    fields: ['value', 'text']
});
czlxxx_message.load();
var czlxxx_message_combo_add = new Ext.form.ComboBox({
    name: 'sttp',
    fieldLabel: '测站类型',
    //emptyText: '请选择',
    mode: 'local',
    editable: false,
    triggerAction: 'all',
    store: czlxxx_message,
    width: 150,
    valueField: 'value', // 值
    displayField: 'text',
    hiddenName: 'sttpdcd',
    allowBlank: true,
    msgTarget: "side"
});
var czlxxx_message_combo_update = new Ext.form.ComboBox({
    name: 'sttp',
    fieldLabel: '测站类型',
    //Text: '请选择',
    mode: 'local',
    editable: false,
    triggerAction: 'all',
    store: czlxxx_message,
    width: 150,
    valueField: 'value', // 值
    displayField: 'text',
    hiddenName: 'sttpcd',
    allowBlank: true,
    msgTarget: "side"
});

var gldw_message = new Ext.data.JsonStore({
    url: '/qtIndex/gldw/combo.action',
    fields: ['value', 'text']
});
gldw_message.load();
var gldw_message_combo_add = new Ext.form.ComboBox({
    name: 'admag',
    fieldLabel: '管理单位',
    emptyText: '请选择',
    mode: 'local',
    editable: true,
    triggerAction: 'all',
    store: gldw_message,
    width: 150,
    valueField: 'value', // 值
    displayField: 'text',
    hiddenName: 'admagcd',
    allowBlank: false,
    msgTarget: "side",
    queryParam: 'userinput',
    forceSelection: true,
    listeners: {
        beforequery: function (qe) {
            var para = qe.query;
        }
    }
});
var gldw_message_combo_update = new Ext.form.ComboBox({
    name: 'admag',
    fieldLabel: '管理单位',
    emptyText: '请选择',
    mode: 'local',
    editable: true,
    triggerAction: 'all',
    store: gldw_message,
    width: 150,
    valueField: 'value', // 值
    displayField: 'text',
    hiddenName: 'admagcd',
    allowBlank: false,
    msgTarget: "side",
    queryParam: 'userinput',
    forceSelection: true,
    listeners: {
        beforequery: function (qe) {
            var para = qe.query;
        }
    }
});

var czflxx_message = new Ext.data.JsonStore({
    url: '/qtIndex/czflxx/combo.action',
    fields: ['value', 'text']
});
czflxx_message.load();
var czflxx_message_combo_add = new Ext.form.ComboBox({
    name: 'stcl',
    fieldLabel: '测站分类',
    //emptyText: '请选择',
    mode: 'local',
    editable: false,
    triggerAction: 'all',
    store: czflxx_message,
    width: 150,
    valueField: 'value', // 值
    displayField: 'text',
    hiddenName: 'stclcd',
    allowBlank: true,
    msgTarget: "side"
});
var czflxx_message_combo_update = new Ext.form.ComboBox({
    name: 'stcl',
    fieldLabel: '测站分类',
    //emptyText: '请选择',
    mode: 'local',
    editable: false,
    triggerAction: 'all',
    store: czflxx_message,
    width: 150,
    valueField: 'value', // 值
    displayField: 'text',
    hiddenName: 'stclcd',
    allowBlank: true,
    msgTarget: "side"
});

var ssxmxx_message = new Ext.data.JsonStore({
    url: '/qtIndex/ssxmxx/combo.action',
    fields: ['value', 'text']
});
ssxmxx_message.load();
var ssxmxx_message_combo_add = new Ext.form.ComboBox({
    name: 'obitnm',
    fieldLabel: '施测项目',
    emptyText: '请选择',
    mode: 'local',
    editable: false,
    triggerAction: 'all',
    store: ssxmxx_message,
    width: 150,
    valueField: 'value', // 值
    displayField: 'text',
    hiddenName: 'obitcd',
    allowBlank: false,
    msgTarget: "side"
});
var ssxmxx_message_combo_update = new Ext.form.ComboBox({
    name: 'obitnm',
    fieldLabel: '施测项目',
    emptyText: '请选择',
    mode: 'local',
    editable: false,
    triggerAction: 'all',
    store: ssxmxx_message,
    width: 150,
    valueField: 'value', // 值
    displayField: 'text',
    hiddenName: 'obitcd',
    allowBlank: false,
    msgTarget: "side"
});

var station_reader = new Ext.data.JsonReader({
    totalProperty: 'totalProperty',
    root: 'root'
}, [
    {
        name: 'stcd'
    },
    {
        name: 'stnm'
    }, {
        name: 'rvcd'
    }, {
        name: 'hncd'
    }, {
        name: 'bscd'
    }, {
        name: 'lgtd'
    }, {
        name: 'lttd'
    }, {
        name: 'addvcd'
    }, {
        name: 'stlc'
    }, {
        name: 'stgrdcd'
    }, {
        name: 'sttpcd'
    }, {
        name: 'obitcd'
    }, {
        name: 'admagcd'
    }, {
        name: 'stclcd'
    }, {
        name: 'nt'
    }, {
        name: 'szm'
    }
]);

var station_addform = new Ext.form.FormPanel({
    labelAlign: 'right',
    frame: true,
    labelWidth: 140,
    url: '/qtIndex/station/add.action',
    bodyStyle: 'padding: 30px 30px 30px 60px',
    reader: station_reader,
    items: [
        {
            xtype: 'textfield',
            fieldLabel: '测站编码',
            readOnly: true,
//                disabled :true,
            width: 150,
            name: 'stcd',
            allowBlank: false,
            msgTarget: "side"
        },
        {
            xtype: 'textfield',
            fieldLabel: '测站名称',
            width: 150,
            emptyText: '请填写',
            name: 'stnm',
            allowBlank: false,
            msgTarget: "side"
        },
        hlxx_message_combo_add,
        sxxx_message_combo_add,
        lyxx_message_combo_add,
        {
            xtype: 'textfield',
            fieldLabel: '经度',
            width: 150,
            name: 'lgtd'
        },
        {
            xtype: 'textfield',
            fieldLabel: '纬度',
            width: 150,
            name: 'lttd'
        },
        xzqh_message_combo_add,
        {
            xtype: 'textfield',
            fieldLabel: '地址',
            width: 150,
            name: 'Stlc'
        },
        czdjxx_message_combo_add,
        czlxxx_message_combo_add,
        //ssxmxx_message_combo_add,
        {
            xtype: 'hidden',
            name: 'obitcd'
        },
        gldw_message_combo_add,
        czflxx_message_combo_add,
        tcflag_combo,
        {
            xtype: 'textarea',
            fieldLabel: '备注',
            width: 150,
            name: 'nt'
        }
    ]
});
var station_updform = new Ext.form.FormPanel({
    labelAlign: 'right',
    frame: true,
    labelWidth: 150,
    url: '/qtIndex/station/update.action',
    bodyStyle: 'padding: 30px 30px 30px 60px',
    reader: station_reader,
    items: [
        {
            xtype: 'textfield',
            fieldLabel: '测站编码',
            readOnly: true,
//                disabled :true,
            width: 150,
            name: 'stcd',
            allowBlank: false,
            msgTarget: "side"
        },
        {
            xtype: 'textfield',
            fieldLabel: '测站名称',
            width: 150,
            name: 'stnm'
        },
        hlxx_message_combo_update,
        sxxx_message_combo_update,
        lyxx_message_combo_update,
        {
            xtype: 'textfield',
            fieldLabel: '经度',
            width: 150,
            name: 'lgtd'
        },
        {
            xtype: 'textfield',
            fieldLabel: '纬度',
            width: 150,
            name: 'lttd'
        },
        xzqh_message_combo_update,
        {
            xtype: 'textfield',
            fieldLabel: '地址',
            width: 150,
            name: 'stlc'
        },
        czdjxx_message_combo_update,
        czlxxx_message_combo_update,
        //ssxmxx_message_combo_update,
        {
            xtype: 'hidden',
            name: 'obitcd'
        },
        gldw_message_combo_update,
        czflxx_message_combo_update,
        tcflag_combo1,
        {
            xtype: 'textfield',
            fieldLabel: '首字母',
            width: 150,
            name: 'szm'
        },
        {
            xtype: 'textarea',
            fieldLabel: '备注',
            width: 150,
            name: 'nt'
        }
    ]
});

//ssk
var stnm_message = new Ext.data.JsonStore({
    url: '/qtIndex/stationIdAndNm/combo.action',
    fields: ['value', 'text']
});
stnm_message.load();
var stnm_message_combo_add = new Ext.form.ComboBox({
    name: 'stnm',
    fieldLabel: '测站名称',
    emptyText: '请选择',
    mode: 'local',
    editable: true,
    triggerAction: 'all',
    store: stnm_message,
    width: 150,
    valueField: 'value', // 值
    displayField: 'text',
    hiddenName: 'stcd',
    allowBlank: false,
    msgTarget: "side",
    queryParam: 'userinput',
    forceSelection: true,
    listeners: {
        beforequery: function (qe) {
            var para = qe.query;
        }
    }
});
var stnm_message_combo_upd = new Ext.form.ComboBox({
    name: 'stnm',
    fieldLabel: '测站名称',
    emptyText: '请选择',
    mode: 'local',
    editable: true,
    triggerAction: 'all',
    store: stnm_message,
    width: 150,
    valueField: 'value', // 值
    displayField: 'text',
    hiddenName: 'stcd',
    allowBlank: false,
    msgTarget: "side",
    queryParam: 'userinput',
    forceSelection: true,
    listeners: {
        beforequery: function (qe) {
            var para = qe.query;
        }
    }
});

var ssxmxx_message = new Ext.data.JsonStore({
    url: '/qtIndex/ssxmxx/combo.action',
    fields: ['value', 'text']
});
ssxmxx_message.load();
var ssxmxx_message_combo_add1 = new Ext.form.ComboBox({
    name: 'obitnm',
    fieldLabel: '施测项目',
    emptyText: '请选择',
    mode: 'local',
    editable: false,
    triggerAction: 'all',
    store: ssxmxx_message,
    width: 150,
    valueField: 'value', // 值
    displayField: 'text',
    hiddenName: 'obitcd',
    allowBlank: false,
    msgTarget: "side"
});
var ssxmxx_message_combo_update1 = new Ext.form.ComboBox({
    name: 'obitnm',
    fieldLabel: '施测项目',
    emptyText: '请选择',
    mode: 'local',
    editable: false,
    triggerAction: 'all',
    store: ssxmxx_message,
    width: 150,
    valueField: 'value', // 值
    displayField: 'text',
    hiddenName: 'obitcd',
    allowBlank: false,
    msgTarget: "side"
});

var mlx_message = new Ext.data.JsonStore({
    url: '/qtIndex/mlx/combo.action',
    fields: ['value', 'text']
});
mlx_message.load();
var mlx_message_combo_add = new Ext.form.ComboBox({
    name: 'tynm',
    fieldLabel: '码类型',
    emptyText: '请选择',
    mode: 'local',
    editable: false,
    triggerAction: 'all',
    store: mlx_message,
    width: 150,
    valueField: 'value', // 值
    displayField: 'text',
    hiddenName: 'tycd',
    allowBlank: false,
    msgTarget: "side"
});
var mlx_message_combo_udp = new Ext.form.ComboBox({
    name: 'tynm',
    fieldLabel: '码类型',
    emptyText: '请选择',
    mode: 'local',
    editable: false,
    triggerAction: 'all',
    store: mlx_message,
    width: 150,
    valueField: 'value', // 值
    displayField: 'text',
    hiddenName: 'tycd',
    allowBlank: false,
    msgTarget: "side"
});

var flag_store = new Ext.data.JsonStore({
    fields: ['value', 'text'],
    data: [
        {text: "是", value: 1},
        {text: "否", value: 0}
    ]
});

var flag_combo = new Ext.form.ComboBox({
    name: 'flag',
    fieldLabel: '优先级',
    emptyText: '请选择',
    mode: 'local',
    editable: false,
    triggerAction: 'all',
    store: flag_store,
    width: 150,
    valueField: 'value', // 值
    displayField: 'text',
    hiddenName: 'first_flag',
    allowBlank: false,
    msgTarget: "side"
});

var sskzmdygx_reader = new Ext.data.JsonReader({
    totalProperty: 'totalProperty',
    root: 'root'
}, [
    {
        name: 'stcd'
    },
    {
        name: 'tycd'
    },
    {
        name: 'obitcd'
    }, {
        name: 'sscd'
    }, {
        name: 'first_flag'
    }, {
        name: 'frdt'
    }, {
        name: 'nt'
    }
]);

var sskzmdygx_addform = new Ext.form.FormPanel({
    labelAlign: 'right',
    frame: true,
    labelWidth: 150,
    url: '/qtIndex/sskzmdygx/add.action',
    bodyStyle: 'padding:30px',
    reader: sskzmdygx_reader,
    items: [
        //stnm_message_combo_add,
        {
            xtype: 'textfield',
            fieldLabel: '测站名称',
            width: 150,
            name: 'stnm'
        },
        {
            xtype: 'hidden',
            name: 'stcd',
        },
        mlx_message_combo_add,
        ssxmxx_message_combo_add1,
        {
            xtype: 'textfield',
            fieldLabel: '站码',
            width: 150,
            name: 'sscd'
        },
        flag_combo,
        {
            xtype: 'datefield',
            fieldLabel: '启用日期',
            width: 150,
            format: 'Y-m-d',
            name: 'frdt',
            emptyText: '请选择',
            allowBlank: true,
            msgTarget: "side"
        },

        {
            xtype: 'textarea',
            fieldLabel: '备注',
            width: 150,
            name: 'nt'
        }
    ]
});
var sskzmdygx_updform = new Ext.form.FormPanel({
    labelAlign: 'right',
    frame: true,
    labelWidth: 150,
    url: '/qtIndex/sskzmdygx/update.action',
    bodyStyle: 'padding:30px',
    reader: sskzmdygx_reader,
    items: [
        stnm_message_combo_upd,
        mlx_message_combo_udp,
        ssxmxx_message_combo_update1,
        {
            xtype: 'textfield',
            fieldLabel: '站码',
            width: 150,
            name: 'sscd'
        },
        {
            xtype: 'datefield',
            fieldLabel: '启用日期',
            width: 150,
            format: 'Y-m-d',
            name: 'frdt',
            emptyText: '请选择',
            allowBlank: true,
            msgTarget: "side"
        },
        {
            xtype: 'textarea',
            fieldLabel: '备注',
            width: 150,
            name: 'nt'
        }
    ]
});

//lsk
var lskzm_reader = new Ext.data.JsonReader({
    totalProperty: 'totalProperty',
    root: 'root'
}, [
    {
        name: 'stcd'
    }, {
        name: 'stnm'
    }, {
        name: 'swswcd'
    }, {
        name: 'ylcd'
    }, {
        name: 'szcd'
    }, {
        name: 'nt'
    }
]);

var lskzm_addform = new Ext.form.FormPanel({
    labelAlign: 'right',
    frame: true,
    height: 220,
    labelWidth: 150,
    url: '/qtIndex/lskzmdygx/add.action',
    bodyStyle: 'padding:30px',
    reader: lskzm_reader,
    items: [
        //stnm_message_combo_add1,
        {
            xtype: 'textfield',
            fieldLabel: '测站名称',
            width: 150,
            name: 'stnm'
        },
        {
            xtype: 'hidden',
            name: 'stcd'
        },
        {
            xtype: 'textfield',
            fieldLabel: '水文水位站码',
            width: 150,
            name: 'swswcd'
        },
        {
            xtype: 'textfield',
            fieldLabel: '雨量站码',
            width: 150,
            name: 'ylcd'
        },
        {
            xtype: 'textfield',
            fieldLabel: '水质站码',
            width: 150,
            name: 'szcd'
        },
        {
            xtype: 'textarea',
            fieldLabel: '备注',
            width: 150,
            name: 'nt'
        }
    ]
});
var lskzm_updform = new Ext.form.FormPanel({
    labelAlign: 'right',
    frame: true,
    height: 220,
    labelWidth: 150,
    url: '/qtIndex/lskzmdygx/update.action',
    bodyStyle: 'padding:30px 30px 30px 60px',
    reader: lskzm_reader,
    items: [
        //stnm_message_combo_upd1,
        {
            xtype: 'hidden',
            name: 'stcd'
        },
        {
            xtype: 'textfield',
            fieldLabel: '测站名称',
            readOnly: true,
            width: 150,
            name: 'stnm'
        },
        {
            xtype: 'textfield',
            fieldLabel: '水文水位站码',
            width: 150,
            name: 'swswcd'
        },
        {
            xtype: 'textfield',
            fieldLabel: '雨量站码',
            width: 150,
            name: 'ylcd'
        },
        {
            xtype: 'textfield',
            fieldLabel: '水质站码',
            width: 150,
            name: 'szcd'
        },
        {
            xtype: 'textarea',
            fieldLabel: '备注',
            width: 150,
            name: 'nt'
        }
    ]
});
var lskzm_viewform = new Ext.form.FormPanel({
    labelAlign: 'right',
    frame: true,
    height: 230,
    labelWidth: 150,
    bodyStyle: 'padding:30px 30px 30px 60px',
    reader: lskzm_reader,
    items: [
        {
            xtype: 'textfield',
            fieldLabel: '测站名称',
            readOnly: true,
            width: 150,
            name: 'stnm'
        },
        {
            xtype: 'hidden',
            name: 'stcd'
        },
        {
            xtype: 'textfield',
            fieldLabel: '水文水位站码',
            readOnly: true,
            width: 150,
            name: 'swswcd'
        },
        {
            xtype: 'textfield',
            fieldLabel: '雨量站码',
            readOnly: true,
            width: 150,
            name: 'ylcd'
        },
        {
            xtype: 'textfield',
            fieldLabel: '水质站码',
            readOnly: true,
            width: 150,
            name: 'szcd'
        },
        {
            xtype: 'textarea',
            fieldLabel: '备注',
            readOnly: true,
            width: 150,
            name: 'nt'
        }
    ]
});

var glcz_message_combo_add = new Ext.form.ComboBox({
    name: 'pstnm',
    fieldLabel: '关联测站名称',
    emptyText: '请选择',
    mode: 'local',
    editable: true,
    triggerAction: 'all',
    store: stnm_message,
    width: 150,
    valueField: 'value', // 值
    displayField: 'text',
    hiddenName: 'pstcd',
    allowBlank: false,
    msgTarget: "side",
    queryParam: 'userinput',
    forceSelection: true,
    listeners: {
        beforequery: function (qe) {
            var para = qe.query;
        }
    }
});
var glcz_message_combo_upd = new Ext.form.ComboBox({
    name: 'pstnm',
    fieldLabel: '关联测站名称',
    emptyText: '请选择',
    mode: 'local',
    readOnly: true,
    triggerAction: 'all',
    store: stnm_message,
    width: 150,
    valueField: 'value', // 值
    displayField: 'text',
    hiddenName: 'pstcd',
    allowBlank: false,
    msgTarget: "side"
});
var glgx_message = new Ext.data.JsonStore({
    url: '/qtIndex/glgx/combo.action',
    fields: ['value', 'text']
});
glgx_message.load();
var glgx_message_combo_add = new Ext.form.ComboBox({
    name: 'relanm',
    fieldLabel: '关联关系',
    emptyText: '请选择',
    mode: 'local',
    editable: true,
    triggerAction: 'all',
    store: glgx_message,
    width: 150,
    valueField: 'value', // 值
    displayField: 'text',
    hiddenName: 'rela',
    allowBlank: false,
    msgTarget: "side",
    queryParam: 'userinput',
    forceSelection: true,
    listeners: {
        beforequery: function (qe) {
            var para = qe.query;
        }
    }
});
var glgx_message_combo_upd = new Ext.form.ComboBox({
    name: 'relanm',
    fieldLabel: '关联关系',
    emptyText: '请选择',
    mode: 'local',
    editable: true,
    triggerAction: 'all',
    store: glgx_message,
    width: 150,
    valueField: 'value', // 值
    displayField: 'text',
    hiddenName: 'rela',
    allowBlank: false,
    msgTarget: "side",
    queryParam: 'userinput',
    forceSelection: true,
    listeners: {
        beforequery: function (qe) {
            var para = qe.query;
        }
    }
});
$(document).ready(function () {
    Ext.QuickTips.init();
    if (role != 0 && role != 1) {
        $("#add_button").attr('style', "display:none");
    }

    $.post("/qtIndex/xzqhName.action", function (data) {
        //console.log(data);
        $("#header").text(data + "水文站一览表");
        if (data == "宁波市") {
            $("#add_button").attr('style', "display:none");
        }

    });

    $('#add_button').on('click', function (e) {
        Ext.onReady(function () {
            var next_flag = 1;
            var stcd = "";
            var stnm = "";
            var add_form = station_addform;
            //var lsk_form = lskzm_addform;
            var lsk_updform = lskzm_updform;
            var add_win = new Ext.Window({
                //layout: 'fit',
                title: '测站添加',
                width: '600',
                height: '600',
                //closable: false,
                closeAction: 'hide',
                constrain: true,
                buttonAlign: 'center',
                resizable: false,
                modal: true,
                plain: true,
                items: [add_form],
                buttons: [
                    {
                        text: '下一步',
                        handler: function () {
                            if (next_flag == 1) {
                                stcd = add_form.getForm().findField('stcd').getValue();
                                stnm = add_form.getForm().findField('stnm').getValue();
                                add_form.getForm().submit({
                                    success: function (form, action) {
                                        add_form.getForm().reset();
                                        next_flag++;
                                        Ext.Ajax.request({
                                            url: '/qtIndex/lskzmdygx/add.action',
                                            params: {
                                                'stcd': stcd,
                                                'swswcd': '',
                                                'ylcd': '',
                                                'szcd': '',
                                                'nt': ''
                                            },
                                            success: function (response) {
                                            }
                                        });
                                    },
                                    failure: function () {
                                        //console.log("fail-1");
                                        Ext.Msg.alert('提示',
                                            '增加失败，请检查输入数据项！', function () {
                                                add_form.getForm().reset();
                                                add_win.hide();
                                            });

                                    }
                                });
                                add_win.removeAll(false);
                                add_win.setTitle("历史库站码对应关系增加");
                                add_win.items.add(lsk_updform);
                                lsk_updform.getForm().findField('stnm').setValue(stnm);

                                var fdm_reader = new Ext.data.JsonReader({
                                    totalProperty: 'totalProperty',
                                    root: 'root'
                                }, [
                                    {
                                        name: 'fdmid'
                                    }, {
                                        name: 'fdmnm'
                                    }, {
                                        name: 'fdmcd'
                                    }
                                ]);

                                var fdm_store = new Ext.data.Store({
                                    proxy: new Ext.data.HttpProxy({
                                        url: '/qtIndex/fdm/showAllFdm.action?stcd=' + stcd
                                    }),
                                    reader: fdm_reader
                                });
                                var fdm_grid_row;

                                var fdm_addform = new Ext.form.FormPanel({
                                    labelAlign: 'right',
                                    frame: true,
                                    labelWidth: 150,
                                    url: '/qtIndex/fdm/add.action?stcd=' + stcd,
                                    bodyStyle: 'padding:30px',
                                    reader: fdm_reader,
                                    items: [
                                        {
                                            xtype: 'textfield',
                                            fieldLabel: '分断面编号',
                                            width: 150,
                                            name: 'fdmid',
                                            maxLength: 2,
                                            minLength: 2,
                                            //maxLengthText: '编号为2位数字',
                                            allowBlank: false,
                                            msgTarget: "side"
                                        },
                                        {
                                            xtype: 'textfield',
                                            fieldLabel: '分断面名称',
                                            width: 150,
                                            name: 'fdmnm',
                                            allowBlank: false,
                                            msgTarget: "side"
                                        },
                                        {
                                            xtype: 'textfield',
                                            fieldLabel: '分断面码',
                                            width: 150,
                                            name: 'fdmcd'
                                        }
                                    ]
                                });
                                var fdmAdd_win = new Ext.Window({
                                    layout: 'fit',
                                    title: '分断面信息添加',
                                    width: '500',
                                    height: '400',
                                    closeAction: 'hide',
                                    constrain: true,
                                    buttonAlign: 'center',
                                    resizable: false,
                                    modal: true,
                                    plain: true,
                                    items: [fdm_addform],
                                    buttons: [
                                        {
                                            text: '增加',
                                            handler: function () {
                                                // alert(JSON.stringify(add_form.getForm().getValues()));
                                                if (fdm_addform.getForm().isValid()) {
                                                    Ext.Ajax.request({
                                                        url: '/qtIndex/fdm/check.action',
                                                        params: {
                                                            stcd: stcd,
                                                            fdmid: fdm_addform.getForm().findField('fdmid').getValue()
                                                        },
                                                        success: function (response) {
                                                            var respText = Ext.util.JSON.decode(response.responseText);
                                                            if (!respText.success) {
                                                                Ext.Msg.alert('提示',
                                                                    '记录已存在！');
                                                            } else {
                                                                fdm_addform.getForm().submit({
                                                                    success: function (form, action) {

                                                                        Ext.Msg.alert('提示',
                                                                            '提交成功！');
                                                                        fdm_addform.getForm().reset();
                                                                        fdmAdd_win.hide();
                                                                        fdm_store.load({
                                                                            params: {
                                                                                start: 0,
                                                                                limit: 30
                                                                            }
                                                                        });
                                                                    },
                                                                    failure: function () {
                                                                        Ext.Msg.alert('提示',
                                                                            '提交失败,请检查输入数据项！');
                                                                    }
                                                                });
                                                            }

                                                        },
                                                        failure: function (response) {
                                                            Ext.Msg.alert('提示',
                                                                '分断面信息检查失败！');
                                                        }

                                                    });
                                                } else {
                                                    Ext.Msg.alert('提示',
                                                        '请检查输入数据项！');
                                                }
                                            }
                                        },
                                        {
                                            text: '取消',
                                            handler: function () {
                                                fdm_addform.getForm().reset();
                                                fdmAdd_win.hide();
                                            }
                                        }
                                    ]
                                });

                                var fdm_updform = new Ext.form.FormPanel({
                                    labelAlign: 'right',
                                    frame: true,
                                    labelWidth: 150,
                                    url: '/qtIndex/fdm/upd.action?stcd=' + stcd,
                                    bodyStyle: 'padding:30px',
                                    reader: fdm_reader,
                                    items: [
                                        {
                                            xtype: 'textfield',
                                            fieldLabel: '分断面编号',
                                            width: 150,
                                            name: 'fdmid',
                                            readOnly: true,
                                            maxLength: 2,
                                            minLength: 2,
                                            //maxLengthText: '编号为2位数字',
                                            allowBlank: false,
                                            msgTarget: "side"
                                        },
                                        {
                                            xtype: 'textfield',
                                            fieldLabel: '分断面名称',
                                            width: 150,
                                            name: 'fdmnm',
                                            allowBlank: false,
                                            msgTarget: "side"
                                        },
                                        {
                                            xtype: 'textfield',
                                            fieldLabel: '分断面码',
                                            width: 150,
                                            name: 'fdmcd'
                                        }
                                    ]
                                });
                                var fdmUpd_win = new Ext.Window({
                                    layout: 'fit',
                                    title: '分断面信息修改',
                                    width: '500',
                                    height: '300',
                                    closeAction: 'hide',
                                    constrain: true,
                                    buttonAlign: 'center',
                                    resizable: false,
                                    modal: true,
                                    plain: true,

                                    items: [fdm_updform],
                                    buttons: [
                                        {
                                            text: '修改',
                                            handler: function () {
                                                if (fdm_updform.getForm().isValid()) {
                                                    fdm_updform.getForm().submit({
                                                        success: function (form, action) {
                                                            Ext.Msg.alert('提示',
                                                                '提交成功！');
                                                            fdm_updform.getForm().reset();
                                                            fdmUpd_win.hide();
                                                            fdm_store.reload({
                                                                params: {
                                                                    start: 0,
                                                                    limit: 30
                                                                }
                                                            });
                                                        },
                                                        failure: function () {
                                                            Ext.Msg.alert('提示',
                                                                '提交失败，请检查输入数据项！');
                                                        }

                                                    });
                                                } else {
                                                    Ext.Msg.alert('提示',
                                                        '请检查输入数据项！');
                                                }

                                            }
                                        },
                                        {
                                            text: '取消',
                                            handler: function () {
                                                fdm_updform.getForm().reset();
                                                fdmUpd_win.hide();
                                            }
                                        }
                                    ]
                                });
                                fdmUpd_win.on('show', function () {
                                    var rec = fdm_store.getAt(fdm_grid_row);
                                    fdm_updform.getForm().loadRecord(rec);
                                });
                                var fdm_colModel = new Ext.grid.ColumnModel([
                                    new Ext.grid.RowNumberer({
                                        header: '编号',
                                        width: 35
                                    }),
                                    {
                                        header: "分断面编号",
                                        sortable: true,
                                        dataIndex: 'fdmid',
                                        width: 370
                                    }, {
                                        header: "分断面名称",
                                        sortable: true,
                                        dataIndex: 'fdmnm',
                                        width: 300
                                    }, {
                                        header: "分断面码",
                                        sortable: true,
                                        dataIndex: 'fdmcd',
                                        width: 300
                                    }
                                    , {
                                        xtype: 'actioncolumn',
                                        header: "操作",
                                        items: [
                                            {
                                                icon: '/ext/cog_edit.png',  // Use a URL in the icon config
                                                tooltip: '修改',
                                                handler: function (grid, rowIndex, colIndex) {
                                                    var rec = fdm_store.getAt(rowIndex);
                                                    fdm_grid_row = rowIndex;
                                                    fdmUpd_win.show();
                                                }
                                            },
                                            {
                                                icon: '/ext/delete.gif',  // Use a URL in the icon config
                                                tooltip: '删除',
                                                handler: function (grid, rowIndex, colIndex) {
                                                    var rec = fdm_store.getAt(rowIndex);
                                                    Ext.MessageBox.confirm('删除', '确认删除？', function (btn) {
                                                        if (btn == 'yes') {
                                                            Ext.Ajax.request({
                                                                url: '/qtIndex/fdm/delete.action',
                                                                params: {
                                                                    stcd: stcd,
                                                                    fdmid: rec.get('fdmid')
                                                                },
                                                                success: function (response) {
                                                                    Ext.Msg.alert('提示',
                                                                        '删除成功！');
                                                                    fdm_store.load({
                                                                        params: {
                                                                            start: 0,
                                                                            limit: 30
                                                                        }
                                                                    });

                                                                },
                                                                failure: function (response) {
                                                                    Ext.Msg.alert('提示',
                                                                        '删除失败！');
                                                                }

                                                            });

                                                        }

                                                    });
                                                }
                                            }

                                        ]
                                    }

                                ]);
                                var fdm_grid = new Ext.grid.GridPanel({
                                    width: 590,
                                    height: 320,
                                    cm: fdm_colModel,
                                    autoExpandColumn: 2,
                                    stripeRows: true,
                                    loadMask: true,
                                    store: fdm_store,
                                    tbar: new Ext.Toolbar(['->',
                                        {
                                            icon: '/ext/add.gif',
                                            tooltip: '增加',
                                            handler: function () {
                                                fdmAdd_win.show();
                                            }
                                        }
                                    ]),
                                    bbar: new Ext.PagingToolbar({
                                        firstText: '1',
                                        pageSize: 30,
                                        store: fdm_store,
                                        displayInfo: true,
                                        displayMsg: '显示第 {0} 到 {1}条记录 ，共 {2}条',
                                        emptyMsg: "没有记录"
                                    }),
                                    viewConfig: {
                                        forceFit: true
                                    }

                                });
                                fdm_store.load({
                                    params: {
                                        start: 0,
                                        limit: 30
                                    }
                                });

                                add_win.items.add(fdm_grid);

                                add_win.doLayout();
                                add_win.show();

                            } else {
                                if (next_flag == 2) {
                                    lsk_updform.getForm().findField('stcd').setValue(stcd);
                                    lsk_updform.getForm().submit({
                                        success: function (form, action) {
                                            lsk_updform.getForm().reset();
                                            //cancel_flag++;
                                        },
                                        failure: function () {
                                            //console.log("fail-2");
                                            Ext.Msg.alert('提示',
                                                '增加失败，请检查输入数据项！');
                                            lsk_updform.getForm().reset();

                                        }
                                    });
                                    add_win.removeAll(false);
                                    add_win.setTitle("实时库站码对应关系增加");
                                    next_flag++;
                                    var sskzmdygx_reader = new Ext.data.JsonReader({
                                        totalProperty: 'totalProperty',
                                        root: 'root'
                                    }, [
                                        {
                                            name: 'stcd'
                                        },
                                        {
                                            name: 'tycd'
                                        },
                                        {
                                            name: 'obitcd'
                                        }, {
                                            name: 'sscd'
                                        }, {
                                            name: 'first_flag'
                                        },
                                        {
                                            name: 'frdt'
                                        },
                                        {
                                            name: 'nt'
                                        }, {
                                            name: 'frtstr'
                                        },
                                        {
                                            name: 'stnm'
                                        },
                                        {
                                            name: 'tynm'
                                        },
                                        {
                                            name: 'obitnm'
                                        },
                                        {
                                            name: 'dtstr'
                                        }
                                    ]);
                                    var sskzmdygx_store = new Ext.data.Store({
                                        proxy: new Ext.data.HttpProxy({
                                            url: '/qtIndex/sskzmdygx/showall.action?stcd=' + stcd
                                        }),
                                        reader: sskzmdygx_reader
                                    });

                                    var sskzmdygx_addform = new Ext.form.FormPanel({
                                        labelAlign: 'right',
                                        frame: true,
                                        labelWidth: 150,
                                        url: '/qtIndex/sskzmdygx/add.action?stcd=' + stcd,
                                        bodyStyle: 'padding:30px',
                                        reader: sskzmdygx_reader,
                                        items: [
                                            // stnm_message_combo_add,
                                            mlx_message_combo_add,
                                            ssxmxx_message_combo_add,
                                            {
                                                xtype: 'textfield',
                                                fieldLabel: '站码',
                                                width: 150,
                                                name: 'sscd'
                                            },
                                            {
                                                xtype: 'textfield',
                                                fieldLabel: '优先级',
                                                width: 150,
                                                maxLength: 1,
                                                name: 'first_flag'
                                            },
                                            //flag_combo,
                                            // {
                                            //     xtype: 'datefield',
                                            //     fieldLabel: '启用日期',
                                            //     width: 150,
                                            //     format: 'Y-m-d',
                                            //     name: 'frdt',
                                            //     emptyText: '请选择',
                                            //     allowBlank: true,
                                            //     msgTarget: "side"
                                            // },
                                            {
                                                xtype: 'datetimefield',
                                                fieldLabel: '启用日期',
                                                width: 150,
                                                format: 'Y-m-d H:i:s',
                                                name: 'frdt',
                                                //emptyText: '请选择',
                                                allowBlank: true,
                                                msgTarget: "side"
                                            },
                                            {
                                                xtype: 'textarea',
                                                fieldLabel: '备注',
                                                width: 150,
                                                name: 'nt'
                                            }
                                        ]
                                    });
                                    //表格的列头
                                    var sszmdygx_colModel = new Ext.grid.ColumnModel([
                                        new Ext.grid.RowNumberer({
                                            header: '编号',
                                            width: 35
                                        }),
                                        {
                                            header: "码类型",
                                            sortable: true,
                                            dataIndex: 'tynm',
                                            width: 370
                                        }, {
                                            header: "施测项目",
                                            sortable: true,
                                            dataIndex: 'obitnm',
                                            width: 300
                                        }, {
                                            header: "站码",
                                            sortable: true,
                                            dataIndex: 'sscd',
                                            width: 300
                                        }, {
                                            header: "优先级",
                                            sortable: true,
                                            dataIndex: 'frtstr',
                                            width: 300
                                        }, {
                                            header: "启用日期",
                                            sortable: true,
                                            dataIndex: 'dtstr',
                                            width: 400
                                        }, {
                                            header: "备注",
                                            sortable: true,
                                            dataIndex: 'nt',
                                            width: 300
                                        }
                                        , {
                                            xtype: 'actioncolumn',
                                            header: "操作",
                                            items: [
                                                {
                                                    icon: '/jsps/qt/images/delete.jpg',  // Use a URL in the icon config
                                                    tooltip: '删除',
                                                    handler: function (grid, rowIndex, colIndex) {
                                                        var rec = sskzmdygx_store.getAt(rowIndex);
                                                        Ext.MessageBox.confirm('删除', '确认删除？', function (btn) {
                                                            if (btn == 'yes') {
                                                                Ext.Ajax.request({
                                                                    url: '/qtIndex/sskzmdygx/delete.action',
                                                                    params: {
                                                                        stcd: rec.get('stcd'),
                                                                        tycd: rec.get('tycd'),
                                                                        obitcd: rec.get('obitcd')

                                                                    },
                                                                    success: function (response) {
                                                                        Ext.Msg.alert('提示',
                                                                            '删除成功！');
                                                                        sskzmdygx_store.load({
                                                                            params: {
                                                                                start: 0,
                                                                                limit: 30
                                                                            }
                                                                        });

                                                                    },
                                                                    failure: function (response) {
                                                                        Ext.Msg.alert('提示',
                                                                            '删除失败！');
                                                                    }

                                                                });

                                                            }

                                                        });
                                                    }
                                                }

                                            ]
                                        }

                                    ]);

                                    var add_subwin = new Ext.Window({
                                        layout: 'fit',
                                        title: '实时库站码对应关系添加',
                                        width: '500',
                                        height: '400',
                                        closeAction: 'hide',
                                        constrain: true,
                                        buttonAlign: 'center',
                                        resizable: false,
                                        modal: true,
                                        plain: true,
                                        items: [sskzmdygx_addform],
                                        buttons: [
                                            {
                                                text: '增加',
                                                handler: function () {
                                                    // alert(JSON.stringify(add_form.getForm().getValues()));
                                                    if (sskzmdygx_addform.getForm().isValid()) {
                                                        Ext.Ajax.request({
                                                            url: '/qtIndex/sskzmdygx/check.action',
                                                            params: {
                                                                sscd: sskzmdygx_addform.getForm().findField('sscd').getValue(),
                                                            },
                                                            success: function (response) {
                                                                var respText = Ext.util.JSON.decode(response.responseText);
                                                                if (!respText.success) {
                                                                    Ext.MessageBox.confirm('提示', '存在相同的站码,确认添加？', function (btn) {
                                                                        if (btn == 'yes') {
                                                                            sskzmdygx_addform.getForm().submit({
                                                                                success: function (form, action) {

                                                                                    Ext.Msg.alert('提示',
                                                                                        '提交成功！');
                                                                                    sskzmdygx_addform.getForm().reset();
                                                                                    add_subwin.hide();
                                                                                    sskzmdygx_store.load({
                                                                                        params: {
                                                                                            start: 0,
                                                                                            limit: 30
                                                                                        }
                                                                                    });
                                                                                },
                                                                                failure: function () {
                                                                                    Ext.Msg.alert('提示',
                                                                                        '提交失败，请检查输入数据项！');
                                                                                }
                                                                            });
                                                                        }
                                                                    });
                                                                } else {
                                                                    sskzmdygx_addform.getForm().submit({
                                                                        success: function (form, action) {

                                                                            Ext.Msg.alert('提示',
                                                                                '提交成功！');
                                                                            sskzmdygx_addform.getForm().reset();
                                                                            add_subwin.hide();
                                                                            sskzmdygx_store.load({
                                                                                params: {
                                                                                    start: 0,
                                                                                    limit: 30
                                                                                }
                                                                            });
                                                                        },
                                                                        failure: function () {
                                                                            Ext.Msg.alert('提示',
                                                                                '提交失败，请检查输入数据项！');
                                                                        }
                                                                    });
                                                                }

                                                            },
                                                            failure: function (response) {
                                                                Ext.Msg.alert('提示',
                                                                    '实时库站码对应关系检查失败！');
                                                            }

                                                        });
                                                    } else {
                                                        Ext.Msg.alert('提示',
                                                            '请检查输入数据项！');
                                                    }
                                                }
                                            },
                                            {
                                                text: '取消',
                                                handler: function () {
                                                    sskzmdygx_addform.getForm().reset();
                                                    add_subwin.hide();
                                                }
                                            }
                                        ]
                                    });

                                    var sszmdygx_grid = new Ext.grid.GridPanel({
                                        // title: "实时站码对应关系",
                                        width: 590,
                                        height: 670,
                                        // renderTo: 'sszmdygx',
//        region:'center',
                                        cm: sszmdygx_colModel,
//        collapsed:true,
                                        autoExpandColumn: 2,
                                        stripeRows: true,
                                        loadMask: true,
                                        store: sskzmdygx_store,
                                        tbar: new Ext.Toolbar(['->',
                                            {
                                                icon: '/ext/add.gif',
                                                tooltip: '增加',
                                                handler: function () {
                                                    add_subwin.show();
                                                }
                                            }
                                        ]),
                                        bbar: new Ext.PagingToolbar({
                                            firstText: '1',
                                            pageSize: 30,
                                            store: sskzmdygx_store,
                                            displayInfo: true,
                                            displayMsg: '显示第 {0} 到 {1}条记录 ，共 {2}条',
                                            emptyMsg: "没有记录"
                                        }),
                                        viewConfig: {
                                            forceFit: true
                                        }

                                    });
                                    sskzmdygx_store.load({
                                        params: {
                                            start: 0,
                                            limit: 30
                                        }
                                    });
                                    add_win.items.add(sszmdygx_grid);
                                    add_win.doLayout();
                                    add_win.show();
                                } else {
                                    if (next_flag == 3) {
                                        add_win.removeAll(false);
                                        add_win.setTitle("测站关联关系增加");
                                        this.setText("完成");
                                        var czglgx_grid_row;
                                        next_flag++;
                                        var czglgx_reader = new Ext.data.JsonReader({
                                            totalProperty: 'totalProperty',
                                            root: 'root'
                                        }, [
                                            {
                                                name: 'stcd'
                                            },
                                            {
                                                name: 'pstcd'
                                            },
                                            {
                                                name: 'rela'
                                            }, {
                                                name: 'formula'
                                            },
                                            {
                                                name: 'frdt'
                                            }, {
                                                name: 'nt'
                                            },
                                            {
                                                name: 'stnm'
                                            },
                                            {
                                                name: 'pstnm'
                                            }, {
                                                name: 'dtstr'
                                            }, {
                                                name: 'relanm'
                                            }
                                        ]);
                                        var czglgx_store = new Ext.data.Store({
                                            proxy: new Ext.data.HttpProxy({
                                                url: '/qtIndex/czglgx/showall.action?stcd=' + stcd
                                            }),
                                            reader: czglgx_reader
                                        });

                                        var czglgx_addform = new Ext.form.FormPanel({
                                            labelAlign: 'right',
                                            frame: true,
                                            labelWidth: 150,
                                            url: '/qtIndex/czglgx/add.action?stcd=' + stcd,
                                            bodyStyle: 'padding:30px',
                                            reader: czglgx_reader,
                                            items: [
                                                //stnm_message_combo_add,
                                                glcz_message_combo_add,
                                                glgx_message_combo_add,
                                                // {
                                                //     xtype: 'textfield',
                                                //     fieldLabel: '关联关系',
                                                //     width: 150,
                                                //     name: 'rela'
                                                // },
                                                {
                                                    xtype: 'textfield',
                                                    fieldLabel: '公式',
                                                    width: 150,
                                                    name: 'formula'
                                                },
                                                {
                                                    xtype: 'datetimefield',
                                                    fieldLabel: '启用日期',
                                                    width: 150,
                                                    format: 'Y-m-d H:i:s',
                                                    name: 'frdt',
                                                    //emptyText: '请选择',
                                                    allowBlank: true,
                                                    msgTarget: "side"
                                                },
                                                {
                                                    xtype: 'textarea',
                                                    fieldLabel: '备注',
                                                    width: 150,
                                                    name: 'nt'
                                                }
                                            ]
                                        });
                                        var czglgx_updform = new Ext.form.FormPanel({
                                            labelAlign: 'right',
                                            frame: true,
                                            labelWidth: 150,
                                            url: '/qtIndex/czglgx/update.action?stcd=' + stcd,
                                            bodyStyle: 'padding:30px',
                                            reader: czglgx_reader,
                                            items: [
                                                glcz_message_combo_upd,
                                                glgx_message_combo_upd,

                                                {
                                                    xtype: 'textfield',
                                                    fieldLabel: '公式',
                                                    width: 150,
                                                    name: 'formula'
                                                },
                                                {
                                                    xtype: 'datetimefield',
                                                    fieldLabel: '启用日期',
                                                    width: 150,
                                                    format: 'Y-m-d H:i:s',
                                                    name: 'frdt',
                                                    //emptyText: '请选择',
                                                    allowBlank: true,
                                                    msgTarget: "side"
                                                },
                                                {
                                                    xtype: 'textarea',
                                                    fieldLabel: '备注',
                                                    width: 150,
                                                    name: 'nt'
                                                }
                                            ]
                                        });
                                        //表格的列头
                                        var czglgx_colModel = new Ext.grid.ColumnModel([
                                            new Ext.grid.RowNumberer({
                                                header: '编号',
                                                width: 35
                                            }),
                                            {
                                                header: "关联测站名称",
                                                sortable: true,
                                                dataIndex: 'pstnm',
                                                width: 150
                                            }, {
                                                header: "关联关系",
                                                sortable: true,
                                                dataIndex: 'relanm',
                                                width: 100
                                            }, {
                                                header: "公式",
                                                sortable: true,
                                                dataIndex: 'formula',
                                                width: 100
                                            },
                                            {
                                                header: "启用时间",
                                                sortable: true,
                                                dataIndex: 'dtstr',
                                                width: 150
                                            }, {
                                                header: "备注",
                                                sortable: true,
                                                dataIndex: 'nt',
                                                width: 150
                                            }
                                            , {
                                                xtype: 'actioncolumn',
                                                header: "操作",
                                                items: [
                                                    {
                                                        icon: '/ext/cog_edit.png',  // Use a URL in the icon config
                                                        tooltip: '修改',
                                                        handler: function (grid, rowIndex, colIndex) {
                                                            //var rec = fdm_store.getAt(rowIndex);
                                                            czglgx_grid_row = rowIndex;
                                                            czglgx_upd_subwin.show();
                                                        }
                                                    },
                                                    {
                                                        icon: '/jsps/qt/images/delete.jpg',  // Use a URL in the icon config
                                                        tooltip: '删除',
                                                        handler: function (grid, rowIndex, colIndex) {
                                                            var rec = czglgx_store.getAt(rowIndex);
                                                            Ext.MessageBox.confirm('删除', '确认删除？', function (btn) {
                                                                if (btn == 'yes') {
                                                                    Ext.Ajax.request({
                                                                        url: '/qtIndex/czglgx/delete.action',
                                                                        params: {
                                                                            stcd: rec.get('stcd'),
                                                                            pstcd: rec.get('pstcd')
                                                                        },
                                                                        success: function (response) {
                                                                            Ext.Msg.alert('提示',
                                                                                '删除成功！');
                                                                            czglgx_store.load({
                                                                                params: {
                                                                                    start: 0,
                                                                                    limit: 30
                                                                                }
                                                                            });

                                                                        },
                                                                        failure: function (response) {
                                                                            Ext.Msg.alert('提示',
                                                                                '删除失败！');
                                                                        }

                                                                    });

                                                                }

                                                            });
                                                        }
                                                    }

                                                ]
                                            }

                                        ]);

                                        var czglgx_add_subwin = new Ext.Window({
                                            layout: 'fit',
                                            title: '测站关联关系添加',
                                            width: '500',
                                            height: '400',
                                            closeAction: 'hide',
                                            constrain: true,
                                            buttonAlign: 'center',
                                            resizable: false,
                                            modal: true,
                                            plain: true,
                                            items: [czglgx_addform],
                                            buttons: [
                                                {
                                                    text: '确认',
                                                    handler: function () {
                                                        // alert(JSON.stringify(add_form.getForm().getValues()));
                                                        if (czglgx_addform.getForm().isValid()) {
                                                            Ext.Ajax.request({
                                                                url: '/qtIndex/czglgx/check.action',
                                                                params: {
                                                                    stcd: stcd,
                                                                    pstcd: czglgx_addform.getForm().findField('pstcd').getValue()
                                                                },
                                                                success: function (response) {
                                                                    var respText = Ext.util.JSON.decode(response.responseText);
                                                                    if (!respText.success) {
                                                                        Ext.Msg.alert('提示', '记录已存在！');
                                                                    } else {
                                                                        czglgx_addform.getForm().submit({
                                                                            success: function (form, action) {

                                                                                Ext.Msg.alert('提示',
                                                                                    '提交成功！');
                                                                                czglgx_addform.getForm().reset();
                                                                                czglgx_add_subwin.hide();
                                                                                czglgx_store.load({
                                                                                    params: {
                                                                                        start: 0,
                                                                                        limit: 30
                                                                                    }
                                                                                });
                                                                            },
                                                                            failure: function () {
                                                                                Ext.Msg.alert('提示',
                                                                                    '提交失败，请检查输入数据项！');
                                                                            }
                                                                        });
                                                                    }

                                                                },
                                                                failure: function (response) {
                                                                    Ext.Msg.alert('提示',
                                                                        '测站关联关系检查失败');
                                                                }

                                                            });
                                                        } else {
                                                            Ext.Msg.alert('提示',
                                                                '请检查输入数据项');
                                                        }
                                                    }
                                                },
                                                {
                                                    text: '取消',
                                                    handler: function () {
                                                        czglgx_addform.getForm().reset();
                                                        czglgx_add_subwin.hide();
                                                    }
                                                }
                                            ]
                                        });
                                        var czglgx_upd_subwin = new Ext.Window({
                                            layout: 'fit',
                                            title: '测站关联关系修改',
                                            width: '500',
                                            height: '400',
                                            closeAction: 'hide',
                                            constrain: true,
                                            buttonAlign: 'center',
                                            resizable: false,
                                            modal: true,
                                            plain: true,
                                            items: [czglgx_updform],
                                            buttons: [
                                                {
                                                    text: '修改',
                                                    handler: function () {
                                                        //alert(JSON.stringify(czglgx_updform.getForm().getValues()));
                                                        if (czglgx_updform.getForm().isValid()) {
                                                            czglgx_updform.getForm().submit({
                                                                success: function (form, action) {

                                                                    Ext.Msg.alert('提示',
                                                                        '提交成功！');
                                                                    czglgx_updform.getForm().reset();
                                                                    czglgx_upd_subwin.hide();
                                                                    czglgx_store.load({
                                                                        params: {
                                                                            start: 0,
                                                                            limit: 30
                                                                        }
                                                                    });
                                                                },
                                                                failure: function () {
                                                                    Ext.Msg.alert('提示',
                                                                        '提交失败，请检查输入数据项！');
                                                                }
                                                            });
                                                        } else {
                                                            Ext.Msg.alert('提示',
                                                                '请检查输入数据项！');
                                                        }

                                                    }
                                                },
                                                {
                                                    text: '取消',
                                                    handler: function () {
                                                        czglgx_updform.getForm().reset();
                                                        czglgx_upd_subwin.hide();
                                                    }
                                                }
                                            ]
                                        });
                                        czglgx_upd_subwin.on('show', function () {
                                            var rec = czglgx_store.getAt(czglgx_grid_row);
                                            czglgx_updform.getForm().loadRecord(rec);
                                            czglgx_updform.getForm().findField('frdt').setValue(rec.get('dtstr'));
                                        });
                                        var caglgx_grid = new Ext.grid.GridPanel({
                                            width: 590,
                                            height: 670,
                                            cm: czglgx_colModel,
//        collapsed:true,
                                            autoExpandColumn: 2,
                                            stripeRows: true,
                                            loadMask: true,
                                            store: czglgx_store,
                                            tbar: new Ext.Toolbar(['->',
                                                {
                                                    icon: '/ext/add.gif',
                                                    tooltip: '增加',
                                                    handler: function () {
                                                        czglgx_add_subwin.show();
                                                    }
                                                }
                                            ]),
                                            bbar: new Ext.PagingToolbar({
                                                firstText: '1',
                                                pageSize: 30,
                                                store: czglgx_store,
                                                displayInfo: true,
                                                displayMsg: '显示第 {0} 到 {1}条记录 ，共 {2}条',
                                                emptyMsg: "没有记录"
                                            }),
                                            viewConfig: {
                                                forceFit: true
                                            }

                                        });
                                        czglgx_store.load({
                                            params: {
                                                start: 0,
                                                limit: 30
                                            }
                                        });
                                        add_win.items.add(caglgx_grid);
                                        add_win.doLayout();
                                        add_win.show();

                                    } else {
                                        add_win.hide();
                                        history.go();
                                    }
                                }
                            }
                        }
                    },
                    {
                        text: '取消',
                        handler: function () {
                            add_win.hide();
                            history.go();
                        }
                    }
                ]
            });

            add_win.on('show', function () {
                Ext.Ajax.request({
                    url: '/qtIndex/station/getCountByAccvcd.action',
                    success: function (resp, opts) {
                        var respText = Ext.util.JSON.decode(resp.responseText);
                        // alert(respText);
                        //stcd = respText;
                        add_form.getForm().findField('stcd').setValue(respText);
                        // $.post("/qtIndex/xzqhName.action", function (data) {
                        xzqh_message_combo_add.setValue(respText.substring(2, 4));
                        // });
                    }
                });
                Ext.Ajax.request({
                    url: '/qtIndex/ssxmxx/checkbox.action',
                    success: function (response) {
                        if (flag_add) {
                            var respText = Ext.util.JSON.decode(response.responseText);
                            //var respText = response.responseText;
                            //console.log(respText);
                            var myCheckboxGroup = new Ext.form.CheckboxGroup(
                                {
                                    id: 'myCheckboxGroup',
                                    xtype: 'checkboxgroup',
                                    fieldLabel: '施测项目',
                                    columns: 3,
                                    readOnly: true,
                                    items: respText
                                });
                            add_form.add(myCheckboxGroup);
                            add_form.doLayout();
                            flag_add = false;

                            myCheckboxGroup.on('change', function (cbgroup, checked) {
                                var str = "";
                                for (var i = 0; i < checked.length; i++) {
                                    str = str + checked[i].getRawValue();
                                }
                                add_form.getForm().findField('obitcd').setValue(str);
                            });
                        }
                    }
                });
            });
            add_form.getForm().findField('tcflag').setValue("0");
            add_form.getForm().findField('lgtd').setValue(0.0);
            add_form.getForm().findField('lttd').setValue(0.0);
            add_win.show();
        });
    });

    var t = $('#station').DataTable({
        serverSide: true,
        ajax: {
            url: '/qtIndex/station/table.action',
            type: 'POST'
        },
        //"serverSide": true,
        "scrollY": 500,
        "scrollX": true,
        "ordering": false,
        "columnDefs": [{
            "searchable": false,
            "orderable": false,
            "targets": 0
        }, {
            'targets': 1,
            // 'checkboxes': {
            //     'selectRow': true
            // }
            'searchable': false,
            'orderable': false,
            'className': 'dt-body-center'
        }, {
            'targets': 17
        }
        ],
        "order": [[1, 'asc']],
        "columns": [
            {"defaultContent": ""},//第0列
            //第1列
            {
                render: function (data, type, full, meta) {
                    return '<input type="checkbox" name="id[]" value="' + full.stcd + '">';
                    //console.log("stcd:"+ full.stcd);
                }
            },
            //第2列
            {
                "data": "stnm",
                "render": function (data, type, full, meta) {
                    return "<a style='text-decoration: none'  href='javascript:void(0)' onclick= viewStation('" + full.stcd + "')>" + data + "</a>";
                    //return "<a style='text-decoration: none'  href='javascript:void(0)' onclick= mapshow('" + full.stcd + "')>" + data + "</a>";
                }
            },
            {
                "data": "stcd", "defaultContent": ""
                // "render": function (data, type, full, meta) {
                //     //return "<a style='text-decoration: none' href= /qt/StationInfo.jsp?iid=" + full.iid + "&fiid="+iid+" >" + data + "</a>";
                // }
            },
            {"data": "rvnm", "defaultContent": ""},
            {"data": "hnnm", "defaultContent": ""},
            {"data": "bsnm", "defaultContent": ""},
            {"data": "lgtd", "defaultContent": ""},
            {"data": "lttd", "defaultContent": ""},
            {"data": "addvnm", "defaultContent": ""},
            {"data": "stlc", "defaultContent": ""},
            {"data": "stgrd", "defaultContent": ""},
            {"data": "obitnm", "defaultContent": ""},
            {"data": "sttp", "defaultContent": ""},
            {"data": "admag", "defaultContent": ""},
            {"data": "stcl", "defaultContent": ""},
            {
                "data": "tcflag", "defaultContent": "",
                render: function (a, b, c, d) {
                    if (c.tcflag == 0) {
                        return "";
                    } else {
                        return "<img src='/jsps/qt/images/true.png'>"
                    }
                }
            },
            {"data": "nt", "defaultContent": ""},
            {
                render: function (a, b, c, d) {
                    //c为当前行的对象
                    // console.log(c);<a onclick= view('" + c.stcd + "')><img src='/jsps/qt/images/view.png' title='查看'>&nbsp;&nbsp;
                    if (role == 0 || role == 1) {
                        return "<a onclick= viewStation('" + c.stcd + "')><img src='/jsps/qt/images/view.png' title='查看'></a>&nbsp;&nbsp;<a onclick= edit('" + c.stcd + "')><img src='/jsps/qt/images/caozuo.png' title='修改'></a>";
                    } else {
                        return "<a onclick= viewStation('" + c.stcd + "')><img src='/jsps/qt/images/view.png' title='查看'></a>";
                    }
                }
            }
        ],
        "pagingType": "full_numbers",
        "pageLength": 30,
        //"dom": '<"toolbar">frtip',
        "dom": '<"toolbar">rtip',
        "language": {
            "lengthMenu": "每页 _MENU_ 条记录",
            "zeroRecords": "没有找到记录",
            "info": "当前显示 _START_ 到 _END_ 条，共 _TOTAL_ 条记录",
            "infoEmpty": "无记录",
            "infoFiltered": "(从 _MAX_ 条记录过滤)",
            "sSearch": "查询:",
            "oPaginate": {
                "sFirst": "首页",
                "sPrevious": " 上一页 ",
                "sNext": " 下一页 ",
                "sLast": " 尾页"
            }
        }
    });

    t.on('draw.dt', function () {
        $('#example-select-all').attr("checked", false);
        t.column(3).visible(false);
        t.column(0, {
            search: 'applied',
            order: 'applied'
        }).nodes().each(function (cell, i) {
            //i 从0开始，所以这里先加1
            i = i + 1;
            //服务器模式下获取分页信息，使用 DT 提供的 API 直接获取分页信息
            var page = t.page.info();
            //当前第几页，从0开始
            var pageno = page.page;
            //每页数据
            var length = page.length;
            //行号等于 页数*每页数据长度+行号
            var columnIndex = (i + pageno * length);
            cell.innerHTML = columnIndex;
        });
    });

    $('#example-select-all').on('click', function () {
        // Get all rows with search applied
        var rows = t.rows({'search': 'applied'}).nodes();
        // Check/uncheck checkboxes for all rows in the table
        $('input[type="checkbox"]', rows).prop('checked', this.checked);
    });
    $('#map').on('click', function (e) {
        // alert(1);
        var str = ""
        t.$('input[type="checkbox"]').each(function () {
            if (this.checked) {
                str += this.value;
                str += "/";
                // console.log(this.value);
            }
        });
        console.log(str);
        if (str == "") {
            //全部显示
            var id = getQueryString("id");
            $("#w").html("<iframe id='MyIframe' frameborder='0'  scrolling='no' src='/qtIndex/map.action?type=all&id=" + id + "' width='100%' height='100%' ></iframe>");
            $('#w').window('open');
        } else {
            //多个点显示
            $("#w").html("<iframe id='MyIframe' frameborder='0'  scrolling='no' src='/qtIndex/map.action?type=duo&iids=" + str + "' width='100%' height='100%' ></iframe>");
            $('#w').window('open');
        }
    });
    $('#search_button').on('click', function () {
        var srh = $("input[name='search_text']").val();
        //$.fn.dataTable.ext.search.push(function( settings, data, dataIndex ) {return srh;});
        t.search(srh).draw();
    });
    $("#search_input").bind('keyup', function (e) {
        if (e.keyCode == 13) {//回车事件
            var srh = $("input[name='search_text']").val();
            //alert(srh);
            t.search(srh).draw();
        }
    });

});

function getQueryString(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
    var r = window.location.search.substr(1).match(reg);
    if (r != null)
        return unescape(r[2]);
    return null;
}

function edit(stcd) {
    Ext.onReady(function () {
            var next_flag = 1;
            var upp_form = station_updform;
            var lsk_updform = lskzm_updform;

            //分断面
            var fdm_reader = new Ext.data.JsonReader({
                totalProperty: 'totalProperty',
                root: 'root'
            }, [
                {
                    name: 'fdmid'
                }, {
                    name: 'fdmnm'
                }, {
                    name: 'fdmcd'
                }
            ]);
            var fdm_store = new Ext.data.Store({
                proxy: new Ext.data.HttpProxy({
                    url: '/qtIndex/fdm/showAllFdm.action?stcd=' + stcd
                }),
                reader: fdm_reader
            });
            var fdm_grid_row;
            var fdm_addform = new Ext.form.FormPanel({
                labelAlign: 'right',
                frame: true,
                labelWidth: 150,
                url: '/qtIndex/fdm/add.action?stcd=' + stcd,
                bodyStyle: 'padding:30px',
                reader: fdm_reader,
                items: [
                    {
                        xtype: 'textfield',
                        fieldLabel: '分断面编号',
                        width: 150,
                        name: 'fdmid',
                        minLength: 2,
                        maxLength: 2,
                        //maxLengthText: '编号为2位数字',
                        allowBlank: false,
                        msgTarget: "side"
                    },
                    {
                        xtype: 'textfield',
                        fieldLabel: '分断面名称',
                        width: 150,
                        name: 'fdmnm',
                        allowBlank: false,
                        msgTarget: "side"

                    },
                    {
                        xtype: 'textfield',
                        fieldLabel: '分断面码',
                        width: 150,
                        name: 'fdmcd',
                        msgTarget: "side"
                    }
                ]
            });
            var fdmAdd_win = new Ext.Window({
                layout: 'fit',
                title: '分断面信息添加',
                width: '500',
                height: '400',
                closeAction: 'hide',
                constrain: true,
                buttonAlign: 'center',
                resizable: false,
                modal: true,
                plain: true,
                items: [fdm_addform],
                buttons: [
                    {
                        text: '增加',
                        handler: function () {
                            // alert(JSON.stringify(add_form.getForm().getValues()));
                            if (fdm_addform.getForm().isValid()) {
                                Ext.Ajax.request({
                                    url: '/qtIndex/fdm/check.action',
                                    params: {
                                        stcd: stcd,
                                        fdmid: fdm_addform.getForm().findField('fdmid').getValue()
                                    },
                                    success: function (response) {
                                        var respText = Ext.util.JSON.decode(response.responseText);
                                        if (!respText.success) {
                                            Ext.Msg.alert('提示',
                                                '记录已存在！');
                                        } else {
                                            fdm_addform.getForm().submit({
                                                success: function (form, action) {

                                                    Ext.Msg.alert('提示',
                                                        '提交成功！');
                                                    fdm_addform.getForm().reset();
                                                    fdmAdd_win.hide();
                                                    fdm_store.load({
                                                        params: {
                                                            start: 0,
                                                            limit: 30
                                                        }
                                                    });
                                                },
                                                failure: function () {
                                                    Ext.Msg.alert('提示',
                                                        '提交失败，请检查输入数据项！');
                                                }
                                            });
                                        }

                                    },
                                    failure: function (response) {
                                        Ext.Msg.alert('提示',
                                            '分断面信息检查失败！');
                                    }

                                });
                            } else {
                                Ext.Msg.alert('提示',
                                    '请检查必填项！');
                            }
                        }
                    },
                    {
                        text: '取消',
                        handler: function () {
                            fdm_addform.getForm().reset();
                            fdmAdd_win.hide();
                        }
                    }
                ]
            });
            var fdm_updform = new Ext.form.FormPanel({
                labelAlign: 'right',
                frame: true,
                labelWidth: 150,
                url: '/qtIndex/fdm/upd.action?stcd=' + stcd,
                bodyStyle: 'padding:30px',
                reader: fdm_reader,
                items: [
                    {
                        xtype: 'textfield',
                        fieldLabel: '分断面编号',
                        width: 150,
                        name: 'fdmid',
                        readOnly: true,
                        maxLength: 2,
                        //maxLengthText: '最多可输入2位',
                        minLength: 2,
                        allowBlank: false,
                        msgTarget: "side"
                    },
                    {
                        xtype: 'textfield',
                        fieldLabel: '分断面名称',
                        width: 150,
                        name: 'fdmnm',
                        allowBlank: false,
                        msgTarget: "side"
                    },
                    {
                        xtype: 'textfield',
                        fieldLabel: '分断面码',
                        width: 150,
                        name: 'fdmcd'
                    }
                ]
            });
            var fdmUpd_win = new Ext.Window({
                layout: 'fit',
                title: '分断面信息修改',
                width: '500',
                height: '300',
                closeAction: 'hide',
                constrain: true,
                buttonAlign: 'center',
                resizable: false,
                modal: true,
                plain: true,

                items: [fdm_updform],
                buttons: [
                    {
                        text: '修改',
                        handler: function () {
                            if (fdm_updform.getForm().isValid()) {
                                fdm_updform.getForm().submit({
                                    success: function (form, action) {
                                        Ext.Msg.alert('提示',
                                            '提交成功！');
                                        fdm_updform.getForm().reset();
                                        fdmUpd_win.hide();
                                        fdm_store.reload({
                                            params: {
                                                start: 0,
                                                limit: 30
                                            }
                                        });
                                    },
                                    failure: function () {
                                        Ext.Msg.alert('提示',
                                            '提交失败，请检查输入数据项！');
                                    }

                                });
                            } else {
                                Ext.Msg.alert('提示',
                                    '请检查输入数据项！');
                            }

                        }
                    },
                    {
                        text: '取消',
                        handler: function () {
                            fdm_updform.getForm().reset();
                            fdmUpd_win.hide();
                        }
                    }
                ]
            });
            fdmUpd_win.on('show', function () {
                var rec = fdm_store.getAt(fdm_grid_row);
                fdm_updform.getForm().loadRecord(rec);
            });
            var fdm_colModel = new Ext.grid.ColumnModel([
                new Ext.grid.RowNumberer({
                    header: '编号',
                    width: 35
                }),
                {
                    header: "分断面编号",
                    sortable: true,
                    dataIndex: 'fdmid',
                    width: 370
                }, {
                    header: "分断面名称",
                    sortable: true,
                    dataIndex: 'fdmnm',
                    width: 300
                }, {
                    header: "分断面码",
                    sortable: true,
                    dataIndex: 'fdmcd',
                    width: 300
                }
                , {
                    xtype: 'actioncolumn',
                    header: "操作",
                    items: [
                        {
                            icon: '/ext/cog_edit.png',  // Use a URL in the icon config
                            tooltip: '修改',
                            handler: function (grid, rowIndex, colIndex) {
                                var rec = fdm_store.getAt(rowIndex);
                                fdm_grid_row = rowIndex;
                                fdmUpd_win.show();
                            }
                        },
                        {
                            icon: '/ext/delete.gif',  // Use a URL in the icon config
                            tooltip: '删除',
                            handler: function (grid, rowIndex, colIndex) {
                                var rec = fdm_store.getAt(rowIndex);
                                Ext.MessageBox.confirm('删除', '确认删除？', function (btn) {
                                    if (btn == 'yes') {
                                        Ext.Ajax.request({
                                            url: '/qtIndex/fdm/delete.action',
                                            params: {
                                                stcd: stcd,
                                                fdmid: rec.get('fdmid')
                                            },
                                            success: function (response) {
                                                Ext.Msg.alert('提示',
                                                    '删除成功！');
                                                fdm_store.load({
                                                    params: {
                                                        start: 0,
                                                        limit: 30
                                                    }
                                                });

                                            },
                                            failure: function (response) {
                                                Ext.Msg.alert('提示',
                                                    '删除失败！');
                                            }

                                        });

                                    }

                                });
                            }
                        }

                    ]
                }

            ]);
            var fdm_grid = new Ext.grid.GridPanel({
                width: 590,
                height: 330,
                cm: fdm_colModel,
                autoExpandColumn: 2,
                stripeRows: true,
                loadMask: true,
                store: fdm_store,
                tbar: new Ext.Toolbar(['->',
                    {
                        icon: '/ext/add.gif',
                        tooltip: '增加',
                        handler: function () {
                            fdmAdd_win.show();
                        }
                    }
                ]),
                bbar: new Ext.PagingToolbar({
                    firstText: '1',
                    pageSize: 30,
                    store: fdm_store,
                    displayInfo: true,
                    displayMsg: '显示第 {0} 到 {1}条记录 ，共 {2}条',
                    emptyMsg: "没有记录"
                }),
                viewConfig: {
                    forceFit: true
                }

            });
            fdm_store.load({
                params: {
                    start: 0,
                    limit: 30
                }
            });

            //实时库
            var sskzmdygx_reader = new Ext.data.JsonReader({
                totalProperty: 'totalProperty',
                root: 'root'
            }, [
                {
                    name: 'stcd'
                },
                {
                    name: 'tycd'
                },
                {
                    name: 'obitcd'
                }, {
                    name: 'sscd'
                }, {
                    name: 'first_flag'
                },
                {
                    name: 'frdt'
                },
                {
                    name: 'nt'
                }, {
                    name: 'frtstr'
                },
                {
                    name: 'stnm'
                },
                {
                    name: 'tynm'
                },
                {
                    name: 'obitnm'
                },
                {
                    name: 'dtstr'
                }
            ]);
            var sskzmdygx_store = new Ext.data.Store({
                proxy: new Ext.data.HttpProxy({
                    url: '/qtIndex/sskzmdygx/showall.action?stcd=' + stcd
                }),
                reader: sskzmdygx_reader
            });
            var sskzmdygx_addform = new Ext.form.FormPanel({
                labelAlign: 'right',
                frame: true,
                labelWidth: 150,
                url: '/qtIndex/sskzmdygx/add.action?stcd=' + stcd,
                bodyStyle: 'padding:30px',
                reader: sskzmdygx_reader,
                items: [
                    // stnm_message_combo_add,
                    mlx_message_combo_add,
                    ssxmxx_message_combo_add,
                    {
                        xtype: 'textfield',
                        fieldLabel: '站码',
                        width: 150,
                        name: 'sscd'
                    },
                    //flag_combo,
                    {
                        xtype: 'textfield',
                        fieldLabel: '优先级',
                        width: 150,
                        maxLength: 1,
                        name: 'first_flag'
                    },
                    {
                        xtype: 'datetimefield',
                        fieldLabel: '启用日期',
                        width: 150,
                        format: 'Y-m-d H:i:s',
                        name: 'frdt',
                        //emptyText: '请选择',
                        allowBlank: true,
                        msgTarget: "side"
                    },
                    {
                        xtype: 'textarea',
                        fieldLabel: '备注',
                        width: 150,
                        name: 'nt'
                    }
                ]
            });
            //表格的列头
            var sszmdygx_colModel = new Ext.grid.ColumnModel([
                new Ext.grid.RowNumberer({
                    header: '编号',
                    width: 35
                }),
                {
                    header: "码类型",
                    sortable: true,
                    dataIndex: 'tynm',
                    width: 100
                }, {
                    header: "施测项目",
                    sortable: true,
                    dataIndex: 'obitnm',
                    width: 100
                }, {
                    header: "站码",
                    sortable: true,
                    dataIndex: 'sscd',
                    width: 100
                }, {
                    header: "优先级",
                    sortable: true,
                    dataIndex: 'frtstr',
                    width: 100
                }, {
                    header: "启用日期",
                    sortable: true,
                    dataIndex: 'dtstr',
                    width: 100
                }, {
                    header: "备注",
                    sortable: true,
                    dataIndex: 'nt',
                    width: 150
                }
                , {
                    xtype: 'actioncolumn',
                    header: "操作",
                    items: [
                        {
                            icon: '/jsps/qt/images/delete.jpg',  // Use a URL in the icon config
                            tooltip: '删除',
                            handler: function (grid, rowIndex, colIndex) {
                                var rec = sskzmdygx_store.getAt(rowIndex);
                                Ext.MessageBox.confirm('删除', '确认删除？', function (btn) {
                                    if (btn == 'yes') {
                                        Ext.Ajax.request({
                                            url: '/qtIndex/sskzmdygx/delete.action',
                                            params: {
                                                stcd: rec.get('stcd'),
                                                tycd: rec.get('tycd'),
                                                obitcd: rec.get('obitcd')

                                            },
                                            success: function (response) {
                                                Ext.Msg.alert('提示',
                                                    '删除成功！');
                                                sskzmdygx_store.load({
                                                    params: {
                                                        start: 0,
                                                        limit: 30
                                                    }
                                                });

                                            },
                                            failure: function (response) {
                                                Ext.Msg.alert('提示',
                                                    '删除失败！');
                                            }

                                        });

                                    }

                                });
                            }
                        }

                    ]
                }

            ]);
            var add_win = new Ext.Window({
                layout: 'fit',
                title: '实时库站码对应关系添加',
                width: '500',
                height: '400',
                closeAction: 'hide',
                constrain: true,
                buttonAlign: 'center',
                resizable: false,
                modal: true,
                plain: true,
                items: [sskzmdygx_addform],
                buttons: [
                    {
                        text: '增加',
                        handler: function () {
                            // alert(JSON.stringify(add_form.getForm().getValues()));
                            if (sskzmdygx_addform.getForm().isValid()) {
                                Ext.Ajax.request({
                                    url: '/qtIndex/sskzmdygx/check.action',
                                    params: {
                                        sscd: sskzmdygx_addform.getForm().findField('sscd').getValue(),
                                    },
                                    success: function (response) {
                                        var respText = Ext.util.JSON.decode(response.responseText);
                                        if (!respText.success) {
                                            Ext.MessageBox.confirm('删除', '存在相同的站码,确认添加？', function (btn) {
                                                if (btn == 'yes') {
                                                    sskzmdygx_addform.getForm().submit({
                                                        success: function (form, action) {

                                                            Ext.Msg.alert('提示',
                                                                '提交成功！');
                                                            sskzmdygx_addform.getForm().reset();
                                                            add_win.hide();
                                                            sskzmdygx_store.load({
                                                                params: {
                                                                    start: 0,
                                                                    limit: 30
                                                                }
                                                            });
                                                        },
                                                        failure: function () {
                                                            Ext.Msg.alert('提示',
                                                                '提交失败，请检查输入的数据项！');
                                                        }
                                                    });
                                                }
                                            });
                                        } else {
                                            sskzmdygx_addform.getForm().submit({
                                                success: function (form, action) {

                                                    Ext.Msg.alert('提示',
                                                        '提交成功！');
                                                    sskzmdygx_addform.getForm().reset();
                                                    add_win.hide();
                                                    sskzmdygx_store.load({
                                                        params: {
                                                            start: 0,
                                                            limit: 30
                                                        }
                                                    });
                                                },
                                                failure: function () {
                                                    Ext.Msg.alert('提示',
                                                        '提交失败，请检查输入数据项！');
                                                }
                                            });
                                        }

                                    },
                                    failure: function (response) {
                                        Ext.Msg.alert('提示',
                                            '实时库站码对应关系检查失败！');
                                    }

                                });
                            } else {
                                Ext.Msg.alert('提示',
                                    '请检查输入数据项！');
                            }


                        }
                    },
                    {
                        text: '取消',
                        handler: function () {
                            sskzmdygx_addform.getForm().reset();
                            add_win.hide();
                        }
                    }
                ]
            });
            var sszmdygx_grid = new Ext.grid.GridPanel({
                width: 590,
                height: 670,
                cm: sszmdygx_colModel,
                autoExpandColumn: 2,
                stripeRows: true,
                loadMask: true,
                store: sskzmdygx_store,
                tbar: new Ext.Toolbar(['->',
                    {
                        icon: '/ext/add.gif',
                        tooltip: '增加',
                        handler: function () {
                            add_win.show();
                        }
                    }
                ]),
                bbar: new Ext.PagingToolbar({
                    firstText: '1',
                    pageSize: 30,
                    store: sskzmdygx_store,
                    displayInfo: true,
                    displayMsg: '显示第 {0} 到 {1}条记录 ，共 {2}条',
                    emptyMsg: "没有记录"
                }),
                viewConfig: {
                    forceFit: true
                }

            });
            sskzmdygx_store.load({
                params: {
                    start: 0,
                    limit: 30
                }
            });

            //测站关联关系
            var czglgx_grid_row;
            var czglgx_reader = new Ext.data.JsonReader({
                totalProperty: 'totalProperty',
                root: 'root'
            }, [
                {
                    name: 'stcd'
                },
                {
                    name: 'pstcd'
                },
                {
                    name: 'rela'
                }, {
                    name: 'formula'
                }, {
                    name: 'frdt'
                }, {
                    name: 'nt'
                },
                {
                    name: 'stnm'
                },
                {
                    name: 'pstnm'
                },
                {
                    name: 'dtstr'
                }, {
                    name: 'relanm'
                }
            ]);
            var czglgx_store = new Ext.data.Store({
                proxy: new Ext.data.HttpProxy({
                    url: '/qtIndex/czglgx/showall.action?stcd=' + stcd
                }),
                reader: czglgx_reader
            });
            var czglgx_addform = new Ext.form.FormPanel({
                labelAlign: 'right',
                frame: true,
                labelWidth: 150,
                url: '/qtIndex/czglgx/add.action?stcd=' + stcd,
                bodyStyle: 'padding:30px',
                reader: czglgx_reader,
                items: [
                    //stnm_message_combo_add,
                    glcz_message_combo_add,
                    glgx_message_combo_add,
                    // {
                    //     xtype: 'textfield',
                    //     fieldLabel: '关联关系',
                    //     width: 150,
                    //     name: 'rela'
                    // },
                    {
                        xtype: 'textfield',
                        fieldLabel: '公式',
                        width: 150,
                        name: 'formula'
                    },
                    {
                        xtype: 'datetimefield',
                        fieldLabel: '启用日期',
                        width: 150,
                        format: 'Y-m-d H:i:s',
                        name: 'frdt',
                        //emptyText: '请选择',
                        allowBlank: true,
                        msgTarget: "side"
                    },
                    {
                        xtype: 'textarea',
                        fieldLabel: '备注',
                        width: 150,
                        name: 'nt'
                    }
                ]
            });
            var czglgx_updform = new Ext.form.FormPanel({
                labelAlign: 'right',
                frame: true,
                labelWidth: 150,
                url: '/qtIndex/czglgx/update.action?stcd=' + stcd,
                bodyStyle: 'padding:30px',
                reader: czglgx_reader,
                items: [
                    glcz_message_combo_upd,
                    glgx_message_combo_upd,
                    {
                        xtype: 'textfield',
                        fieldLabel: '公式',
                        width: 150,
                        name: 'formula'
                    },
                    {
                        xtype: 'datetimefield',
                        fieldLabel: '启用日期',
                        width: 150,
                        format: 'Y-m-d H:i:s',
                        name: 'frdt',
                        //emptyText: '请选择',
                        allowBlank: true,
                        msgTarget: "side"
                    },
                    {
                        xtype: 'textarea',
                        fieldLabel: '备注',
                        width: 150,
                        name: 'nt'
                    }
                ]
            });
            //表格的列头
            var czglgx_colModel = new Ext.grid.ColumnModel([
                new Ext.grid.RowNumberer({
                    header: '编号',
                    width: 35
                }),
                {
                    header: "关联测站名称",
                    sortable: true,
                    dataIndex: 'pstnm',
                    width: 150
                }, {
                    header: "关联关系",
                    sortable: true,
                    dataIndex: 'relanm',
                    width: 100
                }, {
                    header: "公式",
                    sortable: true,
                    dataIndex: 'formula',
                    width: 100
                },
                {
                    header: "启用时间",
                    sortable: true,
                    dataIndex: 'dtstr',
                    width: 150
                },
                {
                    header: "备注",
                    sortable: true,
                    dataIndex: 'nt',
                    width: 150
                }
                , {
                    xtype: 'actioncolumn',
                    header: "操作",
                    items: [
                        {
                            icon: '/ext/cog_edit.png',  // Use a URL in the icon config
                            tooltip: '修改',
                            handler: function (grid, rowIndex, colIndex) {
                                //var rec = fdm_store.getAt(rowIndex);
                                czglgx_grid_row = rowIndex;
                                czglgx_upd_subwin.show();
                            }
                        },
                        {
                            icon: '/jsps/qt/images/delete.jpg',  // Use a URL in the icon config
                            tooltip: '删除',
                            handler: function (grid, rowIndex, colIndex) {
                                var rec = czglgx_store.getAt(rowIndex);
                                Ext.MessageBox.confirm('删除', '确认删除？', function (btn) {
                                    if (btn == 'yes') {
                                        Ext.Ajax.request({
                                            url: '/qtIndex/czglgx/delete.action',
                                            params: {
                                                stcd: rec.get('stcd'),
                                                pstcd: rec.get('pstcd')
                                            },
                                            success: function (response) {
                                                Ext.Msg.alert('提示',
                                                    '删除成功！');
                                                czglgx_store.load({
                                                    params: {
                                                        start: 0,
                                                        limit: 30
                                                    }
                                                });

                                            },
                                            failure: function (response) {
                                                Ext.Msg.alert('提示',
                                                    '删除失败！');
                                            }

                                        });

                                    }

                                });
                            }
                        }

                    ]
                }

            ]);
            var czglgx_add_subwin = new Ext.Window({
                layout: 'fit',
                title: '测站关联关系添加',
                width: '500',
                height: '400',
                closeAction: 'hide',
                constrain: true,
                buttonAlign: 'center',
                resizable: false,
                modal: true,
                plain: true,
                items: [czglgx_addform],
                buttons: [
                    {
                        text: '确认',
                        handler: function () {
                            // alert(JSON.stringify(add_form.getForm().getValues()));
                            if (czglgx_addform.getForm().isValid()) {
                                Ext.Ajax.request({
                                    url: '/qtIndex/czglgx/check.action',
                                    params: {
                                        stcd: stcd,
                                        pstcd: czglgx_addform.getForm().findField('pstcd').getValue()
                                    },
                                    success: function (response) {
                                        var respText = Ext.util.JSON.decode(response.responseText);
                                        if (!respText.success) {
                                            Ext.Msg.alert('提示', '记录已存在！');
                                        } else {
                                            czglgx_addform.getForm().submit({
                                                success: function (form, action) {

                                                    Ext.Msg.alert('提示',
                                                        '提交成功！');
                                                    czglgx_addform.getForm().reset();
                                                    czglgx_add_subwin.hide();
                                                    czglgx_store.load({
                                                        params: {
                                                            start: 0,
                                                            limit: 30
                                                        }
                                                    });
                                                },
                                                failure: function () {
                                                    Ext.Msg.alert('提示',
                                                        '提交失败，请检查输入数据项！');
                                                }
                                            });
                                        }

                                    },
                                    failure: function (response) {
                                        Ext.Msg.alert('提示',
                                            '测站关联关系检查失败！');
                                    }

                                });
                            } else {
                                Ext.Msg.alert('提示',
                                    '请检查输入数据项！');
                            }
                        }
                    },
                    {
                        text: '取消',
                        handler: function () {
                            czglgx_addform.getForm().reset();
                            czglgx_add_subwin.hide();
                        }
                    }
                ]
            });
            var czglgx_upd_subwin = new Ext.Window({
                layout: 'fit',
                title: '测站关联关系修改',
                width: '500',
                height: '400',
                closeAction: 'hide',
                constrain: true,
                buttonAlign: 'center',
                resizable: false,
                modal: true,
                plain: true,
                items: [czglgx_updform],
                buttons: [
                    {
                        text: '修改',
                        handler: function () {
                            //alert(JSON.stringify(czglgx_updform.getForm().getValues()));
                            if (czglgx_updform.getForm().isValid()) {
                                czglgx_updform.getForm().submit({
                                    success: function (form, action) {

                                        Ext.Msg.alert('提示',
                                            '提交成功！');
                                        czglgx_updform.getForm().reset();
                                        czglgx_upd_subwin.hide();
                                        czglgx_store.load({
                                            params: {
                                                start: 0,
                                                limit: 30
                                            }
                                        });
                                    },
                                    failure: function () {
                                        Ext.Msg.alert('提示',
                                            '提交失败，请检查输入数据项！');
                                    }
                                });
                            } else {
                                Ext.Msg.alert('提示',
                                    '请检查输入数据项！');
                            }
                        }
                    },
                    {
                        text: '取消',
                        handler: function () {
                            czglgx_updform.getForm().reset();
                            czglgx_upd_subwin.hide();
                        }
                    }
                ]
            });
            czglgx_upd_subwin.on('show', function () {
                var rec = czglgx_store.getAt(czglgx_grid_row);
                czglgx_updform.getForm().loadRecord(rec);
                czglgx_updform.getForm().findField('frdt').setValue(rec.get('dtstr'));
            });
            var czglgx_grid = new Ext.grid.GridPanel({
                width: 590,
                height: 670,
                cm: czglgx_colModel,
//        collapsed:true,
                autoExpandColumn: 2,
                stripeRows: true,
                loadMask: true,
                store: czglgx_store,
                tbar: new Ext.Toolbar(['->',
                    {
                        icon: '/ext/add.gif',
                        tooltip: '增加',
                        handler: function () {
                            czglgx_add_subwin.show();
                        }
                    }
                ]),
                bbar: new Ext.PagingToolbar({
                    firstText: '1',
                    pageSize: 30,
                    store: czglgx_store,
                    displayInfo: true,
                    displayMsg: '显示第 {0} 到 {1}条记录 ，共 {2}条',
                    emptyMsg: "没有记录"
                }),
                viewConfig: {
                    forceFit: true
                }

            });
            czglgx_store.load({
                params: {
                    start: 0,
                    limit: 30
                }
            });

            //步骤分解 0-测站信息 1-历史库 2-实施库 3-测站关联关系
            var step_0 = function () {
                //upp_win.removeAll(false);
                upp_win.setTitle("测站修改");
                upp_win.items.add(upp_form);
                if (upp_form.isVisible() == false) {
                    upp_form.setVisible(true);
                }
                Ext.Ajax.request({
                    url: '/qtIndex/station/getById.action?id=' + stcd,
                    success: function (resp, opts) {
                        //console.log("response:"+resp);
                        var respText = Ext.util.JSON.decode(resp.responseText);
                        upp_form.getForm().findField('stcd').setValue(respText.stcd);
                        upp_form.getForm().findField('stnm').setValue(respText.stnm);
                        upp_form.getForm().findField('addvcd').setValue(respText.addvcd);
                        upp_form.getForm().findField('stlc').setValue(respText.stlc);
                        upp_form.getForm().findField('lgtd').setValue(respText.lgtd);
                        upp_form.getForm().findField('lttd').setValue(respText.lttd);
                        upp_form.getForm().findField('rvcd').setValue(respText.rvcd);
                        upp_form.getForm().findField('hncd').setValue(respText.hncd);
                        upp_form.getForm().findField('bscd').setValue(respText.bscd);
                        upp_form.getForm().findField('stgrdcd').setValue(respText.stgrdcd);
                        upp_form.getForm().findField('admagcd').setValue(respText.admagcd);
                        upp_form.getForm().findField('stclcd').setValue(respText.stclcd);
                        upp_form.getForm().findField('sttpcd').setValue(respText.sttpcd);
                        upp_form.getForm().findField('obitcd').setValue(respText.obitcd);
                        upp_form.getForm().findField('tcflag').setValue(respText.tcflag);
                        upp_form.getForm().findField('szm').setValue(respText.szm);
                        upp_form.getForm().findField('nt').setValue(respText.nt);
                        // if (respText.nt != '') {
                        //     upp_form.getForm().findField('nt').setValue(respText.nt);
                        // }
                    }

                });
                var flag_upd = true;
                Ext.Ajax.request({
                    url: '/qtIndex/ssxmxx/checkboxUpd.action?stcd=' + stcd,
                    success: function (response) {
                        if (flag_upd) {
                            var respText = Ext.util.JSON.decode(response.responseText);
                            upp_form.items.each(function (C) {
                                    if (C == Ext.getCmp("myCheckboxGroup1")) {
                                        upp_form.remove(C, true);
                                        upp_form.doLayout();
                                    }
                                }
                            );
                            var myCheckboxGroup1 = new Ext.form.CheckboxGroup(
                                {
                                    id: 'myCheckboxGroup1',
                                    xtype: 'checkboxgroup',
                                    fieldLabel: '施测项目',
                                    columns: 3,
                                    readOnly: true,
                                    items: respText
                                });
                            upp_form.add(myCheckboxGroup1);
                            upp_form.doLayout();
                            flag_upd = false;

                            myCheckboxGroup1.on('change', function (cbgroup, checked) {
                                var str = "";
                                for (var i = 0; i < checked.length; i++) {
                                    str = str + checked[i].getRawValue();
                                }
                                upp_form.getForm().findField('obitcd').setValue(str);
                            });
                        }
                    }
                });
                Ext.getCmp('pre_button').hide();
                upp_win.doLayout();
                upp_win.show();
                next_flag++;
            };
            var step_1 = function () {
                //upp_win.removeAll(false);
                upp_win.setTitle("历史库站码对应关系修改");
                Ext.getCmp("next_button").setText("下一步");
                upp_win.items.add(lsk_updform);
                Ext.Ajax.request({
                    url: '/qtIndex/lskzmdygx/getById.action?id=' + stcd,
                    success: function (resp, opts) {
                        //console.log("response:"+resp);
                        var respText = Ext.util.JSON.decode(resp.responseText);
                        lsk_updform.getForm().findField('stcd').setValue(respText.stcd);
                        lsk_updform.getForm().findField('stnm').setValue(respText.stnm);
                        lsk_updform.getForm().findField('swswcd').setValue(respText.swswcd);
                        lsk_updform.getForm().findField('ylcd').setValue(respText.ylcd);
                        lsk_updform.getForm().findField('szcd').setValue(respText.szcd);
                        lsk_updform.getForm().findField('nt').setValue(respText.nt);
                    },
                    failure: function () {
                        Ext.Msg.alert('提示',
                            '历史库站码对应关系读取失败！');
                    }

                });
                upp_win.items.add(fdm_grid);
                if (lsk_updform.isVisible() == false) {
                    lsk_updform.setVisible(true);
                }
                if (fdm_grid.isVisible() == false) {
                    fdm_grid.setVisible(true);
                }
                Ext.getCmp('pre_button').show();
                upp_win.doLayout();
                upp_win.show();
                next_flag++;
            };
            var step_2 = function () {
                //upp_win.removeAll(false);
                upp_win.setTitle("实时库站码对应关系修改");
                Ext.getCmp("next_button").setText("下一步");
                upp_win.items.add(sszmdygx_grid);
                if (sszmdygx_grid.isVisible() == false) {
                    sszmdygx_grid.setVisible(true);
                }
                upp_win.doLayout();
                upp_win.show();
                next_flag++;
            };
            var step_3 = function () {
                //upp_win.removeAll(false);
                upp_win.setTitle("测站关联关系修改");
                Ext.getCmp("next_button").setText("完成");
                next_flag++;
                upp_win.items.add(czglgx_grid);
                if (czglgx_grid.isVisible() == false) {
                    czglgx_grid.setVisible(true);
                }
                upp_win.doLayout();
                upp_win.show();
            };

            var upp_win = new Ext.Window({
                //layout: 'fit',
                title: '测站修改',
                width: '600',
                height: '610',
                closeAction: 'hide',
                constrain: true,
                buttonAlign: 'center',
                resizable: false,
                modal: true,
                plain: true,
                items: [upp_form],
                buttons: [
                    {
                        id: 'pre_button',
                        text: '上一步',
                        handler: function () {
                            next_flag = next_flag - 2;
                            if (next_flag == 0) {
                                //alert("pre-" + next_flag);
                                lsk_updform.setVisible(false);
                                fdm_grid.setVisible(false);
                                step_0();
                            } else if (next_flag == 1) {
                                //alert("pre-" + next_flag);
                                sszmdygx_grid.setVisible(false);
                                step_1();
                            } else if (next_flag == 2) {
                                czglgx_grid.setVisible(false);
                                step_2();
                            }
                        }
                    },
                    {
                        id: 'next_button',
                        text: '下一步',
                        handler: function () {
                            if (next_flag == 1) {
                                if (upp_form.getForm().isValid()) {
                                    upp_form.getForm().submit({
                                        success: function (form, action) {
                                            upp_form.getForm().reset();
                                            upp_form.setVisible(false);
                                            step_1();
                                        },
                                        failure: function () {
                                            Ext.Msg.alert('提示',
                                                '提交失败，请检查输入数据项！');
                                            upp_form.getForm().reset();
                                        }
                                    });
                                }
                            } else if (next_flag == 2) {
                                if (lsk_updform.getForm().isValid()) {
                                    lsk_updform.getForm().submit({
                                        success: function (form, action) {
                                            lsk_updform.getForm().reset();
                                            lsk_updform.setVisible(false);
                                            fdm_grid.setVisible(false);
                                            step_2();
                                        },
                                        failure: function () {
                                            Ext.Msg.alert('提示',
                                                '提交失败，请检查输入数据项！');
                                            lsk_updform.getForm().reset();
                                        }
                                    });
                                }
                            } else if (next_flag == 3) {
                                sszmdygx_grid.setVisible(false);
                                step_3();
                            } else {
                                upp_win.hide();
                                history.go();
                            }

                        }
                    },
                    {
                        text: '取消',
                        handler: function () {
                            upp_win.hide();
                            history.go();
                        }
                    }
                ]
            });

            upp_win.on('show', function () {
                if (upp_form.isVisible() == false) {
                    upp_form.setVisible(true);
                }
                Ext.Ajax.request({
                    url: '/qtIndex/station/getById.action?id=' + stcd,
                    success: function (resp, opts) {
                        //console.log("response:"+resp);
                        var respText = Ext.util.JSON.decode(resp.responseText);
                        upp_form.getForm().findField('stcd').setValue(respText.stcd);
                        upp_form.getForm().findField('stnm').setValue(respText.stnm);
                        upp_form.getForm().findField('addvcd').setValue(respText.addvcd);
                        upp_form.getForm().findField('stlc').setValue(respText.stlc);
                        upp_form.getForm().findField('lgtd').setValue(respText.lgtd);
                        upp_form.getForm().findField('lttd').setValue(respText.lttd);
                        upp_form.getForm().findField('rvcd').setValue(respText.rvcd);
                        upp_form.getForm().findField('hncd').setValue(respText.hncd);
                        upp_form.getForm().findField('bscd').setValue(respText.bscd);
                        upp_form.getForm().findField('stgrdcd').setValue(respText.stgrdcd);
                        upp_form.getForm().findField('admagcd').setValue(respText.admagcd);
                        upp_form.getForm().findField('stclcd').setValue(respText.stclcd);
                        upp_form.getForm().findField('sttpcd').setValue(respText.sttpcd);
                        upp_form.getForm().findField('obitcd').setValue(respText.obitcd);
                        upp_form.getForm().findField('tcflag').setValue(respText.tcflag);
                        upp_form.getForm().findField('szm').setValue(respText.szm);
                        upp_form.getForm().findField('nt').setValue(respText.nt);
                        // if (respText.nt != '') {
                        //     upp_form.getForm().findField('nt').setValue(respText.nt);
                        // }
                    }

                });
                var flag_upd = true;
                Ext.Ajax.request({
                    url: '/qtIndex/ssxmxx/checkboxUpd.action?stcd=' + stcd,
                    success: function (response) {
                        if (flag_upd) {
                            var respText = Ext.util.JSON.decode(response.responseText);
                            upp_form.items.each(function (C) {
                                    if (C == Ext.getCmp("myCheckboxGroup1")) {
                                        upp_form.remove(C, true);
                                        upp_form.doLayout();
                                    }
                                }
                            );
                            var myCheckboxGroup1 = new Ext.form.CheckboxGroup(
                                {
                                    id: 'myCheckboxGroup1',
                                    xtype: 'checkboxgroup',
                                    fieldLabel: '施测项目',
                                    columns: 3,
                                    readOnly: true,
                                    items: respText
                                });
                            upp_form.add(myCheckboxGroup1);
                            upp_form.doLayout();
                            flag_upd = false;

                            myCheckboxGroup1.on('change', function (cbgroup, checked) {
                                var str = "";
                                for (var i = 0; i < checked.length; i++) {
                                    str = str + checked[i].getRawValue();
                                }
                                upp_form.getForm().findField('obitcd').setValue(str);
                            });
                        }
                    }
                });
                Ext.getCmp('pre_button').hide();
            });

            upp_win.show();

        }
    )
    ;
}

function viewStation(stcd) {
    Ext.onReady(function () {
        var next_flag = 1;
        var view_form = lskzm_viewform;

        //分断面信息
        var fdm_reader = new Ext.data.JsonReader({
            totalProperty: 'totalProperty',
            root: 'root'
        }, [
            {
                name: 'fdmid'
            }, {
                name: 'fdmnm'
            }, {
                name: 'fdmcd'
            }
        ]);
        var fdm_store = new Ext.data.Store({
            proxy: new Ext.data.HttpProxy({
                url: '/qtIndex/fdm/showAllFdm.action?stcd=' + stcd
            }),
            reader: fdm_reader
        });
        var fdm_colModel = new Ext.grid.ColumnModel([
            new Ext.grid.RowNumberer({
                header: '编号',
                width: 35
            }),
            {
                header: "分断面编号",
                sortable: true,
                dataIndex: 'fdmid',
                width: 100
            }, {
                header: "分断面名称",
                sortable: true,
                dataIndex: 'fdmnm',
                width: 100
            }, {
                header: "分断面码",
                sortable: true,
                dataIndex: 'fdmcd',
                width: 100
            }

        ]);
        var fdm_grid = new Ext.grid.GridPanel({
            width: 587,
            height: 305,
            cm: fdm_colModel,
            autoExpandColumn: 2,
            stripeRows: true,
            loadMask: true,
            store: fdm_store,
            bbar: new Ext.PagingToolbar({
                firstText: '1',
                pageSize: 30,
                store: fdm_store,
                displayInfo: true,
                displayMsg: '显示第 {0} 到 {1}条记录 ，共 {2}条',
                emptyMsg: "没有记录"
            }),
            viewConfig: {
                forceFit: true
            }

        });
        fdm_store.load({
            params: {
                start: 0,
                limit: 30
            }
        });

        //实时库信息
        var sskzmdygx_reader = new Ext.data.JsonReader({
            totalProperty: 'totalProperty',
            root: 'root'
        }, [
            {
                name: 'stcd'
            },
            {
                name: 'tycd'
            },
            {
                name: 'obitcd'
            }, {
                name: 'sscd'
            }, {
                name: 'first_flag'
            },
            {
                name: 'frdt'
            },
            {
                name: 'nt'
            }, {
                name: 'frtstr'
            },
            {
                name: 'stnm'
            },
            {
                name: 'tynm'
            },
            {
                name: 'obitnm'
            },
            {
                name: 'dtstr'
            }
        ]);
        var sskzmdygx_store = new Ext.data.Store({
            proxy: new Ext.data.HttpProxy({
                url: '/qtIndex/sskzmdygx/showall.action?stcd=' + stcd
            }),
            reader: sskzmdygx_reader
        });
        var sszmdygx_colModel = new Ext.grid.ColumnModel([
            new Ext.grid.RowNumberer({
                header: '编号',
                width: 35
            }),
            {
                header: "码类型",
                sortable: true,
                dataIndex: 'tynm',
                width: 100
            }, {
                header: "施测项目",
                sortable: true,
                dataIndex: 'obitnm',
                width: 100
            }, {
                header: "站码",
                sortable: true,
                dataIndex: 'sscd',
                width: 100
            }, {
                header: "优先级",
                sortable: true,
                dataIndex: 'frtstr',
                width: 100
            }, {
                header: "启用日期",
                sortable: true,
                dataIndex: 'dtstr',
                width: 100
            }, {
                header: "备注",
                sortable: true,
                dataIndex: 'nt',
                width: 150
            }
        ]);
        var sszmdygx_grid = new Ext.grid.GridPanel({
            width: 600,
            height: 600,
            cm: sszmdygx_colModel,
            autoExpandColumn: 2,
            stripeRows: true,
            loadMask: true,
            store: sskzmdygx_store,
            bbar: new Ext.PagingToolbar({
                firstText: '1',
                pageSize: 30,
                store: sskzmdygx_store,
                displayInfo: true,
                displayMsg: '显示第 {0} 到 {1}条记录 ，共 {2}条',
                emptyMsg: "没有记录"
            }),
            viewConfig: {
                forceFit: true
            }

        });
        sskzmdygx_store.load({
            params: {
                start: 0,
                limit: 30
            }
        });

        //测站关联关系
        var czglgx_reader = new Ext.data.JsonReader({
            totalProperty: 'totalProperty',
            root: 'root'
        }, [
            {
                name: 'stcd'
            },
            {
                name: 'pstcd'
            },
            {
                name: 'rela'
            }, {
                name: 'formula'
            },
            {
                name: 'frdt'
            }, {
                name: 'nt'
            },
            {
                name: 'stnm'
            },
            {
                name: 'pstnm'
            },
            {
                name: 'dtstr'
            }, {
                name: 'relanm'
            }
        ]);
        var czglgx_store = new Ext.data.Store({
            proxy: new Ext.data.HttpProxy({
                url: '/qtIndex/czglgx/showall.action?stcd=' + stcd
            }),
            reader: czglgx_reader
        });
        var czglgx_colModel = new Ext.grid.ColumnModel([
            new Ext.grid.RowNumberer({
                header: '编号',
                width: 35
            }),
            {
                header: "关联测站名称",
                sortable: true,
                dataIndex: 'pstnm',
                width: 150
            }, {
                header: "关联关系",
                sortable: true,
                dataIndex: 'relanm',
                width: 100
            }, {
                header: "公式",
                sortable: true,
                dataIndex: 'formula',
                width: 100
            }, {
                header: "启用时间",
                sortable: true,
                dataIndex: 'dtstr',
                width: 150
            }, {
                header: "备注",
                sortable: true,
                dataIndex: 'nt',
                width: 150
            }

        ]);
        var czglgx_grid = new Ext.grid.GridPanel({
            width: 600,
            height: 600,
            cm: czglgx_colModel,
//        collapsed:true,
            autoExpandColumn: 2,
            stripeRows: true,
            loadMask: true,
            store: czglgx_store,
            bbar: new Ext.PagingToolbar({
                firstText: '1',
                pageSize: 30,
                store: czglgx_store,
                displayInfo: true,
                displayMsg: '显示第 {0} 到 {1}条记录 ，共 {2}条',
                emptyMsg: "没有记录"
            }),
            viewConfig: {
                forceFit: true
            }

        });
        czglgx_store.load({
            params: {
                start: 0,
                limit: 30
            }
        });

        var view_step_0 = function () {
            view_win.setTitle("历史库站码对应关系");
            view_win.items.add(view_form);
            if (view_form.isVisible() == false) {
                view_form.setVisible(true);
            }
            Ext.Ajax.request({
                url: '/qtIndex/lskzmdygx/getById.action?id=' + stcd,
                success: function (resp, opts) {
                    //console.log("response:"+resp);
                    var respText = Ext.util.JSON.decode(resp.responseText);
                    view_form.getForm().findField('stcd').setValue(respText.stcd);
                    view_form.getForm().findField('stnm').setValue(respText.stnm);
                    view_form.getForm().findField('swswcd').setValue(respText.swswcd);
                    view_form.getForm().findField('ylcd').setValue(respText.ylcd);
                    view_form.getForm().findField('szcd').setValue(respText.szcd);
                    view_form.getForm().findField('nt').setValue(respText.nt);
                }

            });
            view_win.items.add(fdm_grid);
            if (fdm_grid.isVisible() == false) {
                fdm_grid.setVisible(true);
            }
            Ext.getCmp('pre_button_view').hide();
            view_win.doLayout();
            view_win.show();
            next_flag++;
        };
        var view_step_1 = function () {
            view_win.setTitle("实时库站码对应关系");
            view_win.items.add(sszmdygx_grid);
            if(sszmdygx_grid.isVisible() == false){
                sszmdygx_grid.setVisible(true);
            }
            Ext.getCmp("next_button_view").setText("下一步");
            Ext.getCmp('pre_button_view').show();
            view_win.doLayout();
            view_win.show();
            next_flag++;
        };
        var view_step_2 = function () {
            view_win.setTitle("测站关联关系");
            view_win.items.add(czglgx_grid);
            if(czglgx_grid.isVisible() == false){
                czglgx_grid.setVisible(true);
            }
            Ext.getCmp("next_button_view").setText("关闭");
            view_win.doLayout();
            view_win.show();
            next_flag++;
        };

        var view_win = new Ext.Window({
            //layout: 'fit',
            title: '历史库站码对应关系',
            width: '600',
            height: '600',
            closeAction: 'hide',
            constrain: true,
            buttonAlign: 'center',
            resizable: false,
            modal: true,
            plain: true,
            items: [view_form],
            buttons: [
                {
                    id: 'pre_button_view',
                    text: '上一步',
                    handler: function () {
                        next_flag = next_flag - 2;
                        if (next_flag == 0) {
                            sszmdygx_grid.setVisible(false);
                            view_step_0();
                        } else if (next_flag == 1) {
                            czglgx_grid.setVisible(false);
                            view_step_1();
                        }
                    }
                },
                {
                    id: 'next_button_view',
                    text: '下一步',
                    handler: function () {
                        if (next_flag == 1) {
                            view_form.setVisible(false);
                            fdm_grid.setVisible(false);
                            view_step_1();
                        } else {
                            if (next_flag == 2) {
                                sszmdygx_grid.setVisible(false);
                                view_step_2();
                            } else {
                                view_win.hide();
                            }

                        }
                    }
                }
            ]
        });

        view_win.on('show', function () {
            Ext.Ajax.request({
                url: '/qtIndex/lskzmdygx/getById.action?id=' + stcd,
                success: function (resp, opts) {
                    //console.log("response:"+resp);
                    var respText = Ext.util.JSON.decode(resp.responseText);
                    view_form.getForm().findField('stcd').setValue(respText.stcd);
                    view_form.getForm().findField('stnm').setValue(respText.stnm);
                    view_form.getForm().findField('swswcd').setValue(respText.swswcd);
                    view_form.getForm().findField('ylcd').setValue(respText.ylcd);
                    view_form.getForm().findField('szcd').setValue(respText.szcd);
                    view_form.getForm().findField('nt').setValue(respText.nt);
                }
            });
            view_win.items.add(fdm_grid);
            Ext.getCmp('pre_button_view').hide();
            view_form.setVisible(true);
            fdm_grid.setVisible(true);
            sszmdygx_grid.setVisible(false);
            czglgx_grid.setVisible(false);
        });

        view_win.show();

    });
}

function mapshow(stcd) {
    // alert(c);
    $("#w").html("<iframe id='MyIframe' frameborder='0'  scrolling='no' src='/qtIndex/map.action?type=duo&iids=" + stcd + "' width='100%' height='100%' ></iframe>");
    $('#w').window('open');
}


